SheetControls = {
    SheetAttachment: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "AllowBatchDownload",
            Description: "获取或设置是否允许批量下载",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {
            Name: "FileExtensions",
            Description: "获取或设置附件上传的文件名格式,示例:.jpg,.gif",
            DefaultValue: "",
            ValueRange: null
        }, {Name: "MaxUploadSize", Description: "获取或设置限制文件上传的大小(MB)，默认为 10MB", DefaultValue: 10, ValueRange: null}]
    },
    SheetCheckbox: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DefaultValue",
            Description: "获取或设置控件的默认值",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {Name: "Text", Description: "获取或设置控件的文本说明", DefaultValue: "", ValueRange: null}],
        DesignEvents: [{Name: "OnChange", Description: "获取或设置选项值改变事件"}]
    },
    SheetCheckboxList: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DefaultItems",
            Description: "获取或设置绑定的选项值，多个值以;隔开",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DisplayRule",
            Description: "获取或设置控件的显示规则",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "MasterDataCategory",
            Description: "获取或设置绑定的数据字典类型名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "RepeatColumns",
            Description: "获取或设置要在控件中显示的列数",
            DefaultValue: "5",
            ValueRange: null
        }, {
            Name: "RepeatDirection",
            Description: "获取或设置组中单选按钮的显示方向",
            DefaultValue: "Horizontal",
            ValueRange: ["Horizontal", "Vertical"]
        }, {
            Name: "SelectedValue",
            Description: "获取或设置控件选中的值",
            DefaultValue: "",
            ValueRange: null
        }, {Name: "VaildationRule", Description: "获取或设置控件的验证规则，为True时必填!", DefaultValue: "", ValueRange: null}],
        DesignEvents: [{Name: "OnChange", Description: "获取或设置选择和取消选择事件"}]
    },
    SheetComment: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DefaultComment",
            Description: "获取或设置默认审批意见",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DisplaySign",
            Description: "获取或设置是否显示用户签名",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "DisplayHead",
            Description: "获取或设置是否显示用户头像",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {
            Name: "DisplayBorder",
            Description: "获取或设置历史意见是否显示边框",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {
            Name: "FrequentCommentVisible",
            Description: "获取或设置是否显示常用意见",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {
            Name: "FrequentSettingVisible",
            Description: "获取或设置是否显示设置为常用意见",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {
            Name: "LastestCommentOnly",
            Description: "获取或设置是否显示最后一条意见",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "NullCommentTitleVisible",
            Description: "获取或设置当意见为空时是否显示意见标题",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {
            Name: "OUNameVisible",
            Description: "获取或设置是否显示OU名称",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "ActivityNameVisible",
            Description: "获取或设置是否显示活动节点名称",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {Name: "DateNewLine", Description: "获取或设置签名和日期是否换行", DefaultValue: false, ValueRange: [true, false]}]
    },
    SheetDropDownList: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DefaultItems",
            Description: "获取或设置绑定的默认值，多个值以&quot;;&quot;号隔开",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DisplayEmptyItem",
            Description: "获取或设置是否默认显示空项",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "EmptyItemText",
            Description: "获取或设置空项显示文本",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DisplayRule",
            Description: "获取或设置控件的显示规则。",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "MasterDataCategory",
            Description: "获取或设置绑定数据字典的类型",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "Queryable",
            Description: "获取或设置是否允许对项目进行搜索",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {
            Name: "SchemaCode",
            Description: "获取或设置绑定的业务对象名称",
            DefaultValue: "",
            ValueRange: null,
            Popup: "DropDownListSetting",
            Height: 450,
            Width: 540
        }, {
            Name: "QueryCode",
            Description: "获取或设置业务对象的查询编码",
            DefaultValue: "",
            ValueRange: null,
            Popup: "DropDownListSetting",
            Height: 450,
            Width: 540
        }, {
            Name: "Filter",
            Description: "获取或设置过滤条件，例如&quot;数据项:查询字段1,控件ID:查询字段2,固定值:查询字段3&quot;",
            DefaultValue: "",
            ValueRange: null,
            Popup: "DropDownListSetting",
            Height: 450,
            Width: 540
        }, {
            Name: "DataValueField",
            Description: "获取或设置数据源绑定时显示的值字段的名称",
            DefaultValue: "",
            ValueRange: null,
            Popup: "DropDownListSetting",
            Height: 450,
            Width: 540
        }, {
            Name: "DataTextField",
            Description: "获取或设置数据源绑定时显示的文本字段的名称",
            DefaultValue: "",
            ValueRange: null,
            Popup: "DropDownListSetting",
            Height: 450,
            Width: 540
        }, {
            Name: "SelectedValue",
            Description: "获取或设置下拉框选定的值",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "TextDataField",
            Description: "获取或设置存储选中项文本值的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "VaildationRule",
            Description: "获取或设置控件的验证规则，为True时必填!",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "ViewInNewContainer",
            Description: "获取或设置在移动端是否显示到新窗口",
            DefaultValue: false,
            ValueRange: [true, false]
        }], DesignEvents: [{Name: "OnChange", Description: "获取或设置数据改变时执行脚本"}]
    },
    SheetGridView: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DisplayAdd",
            Description: "获取或设置是否显示添加按钮",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {
            Name: "DisplayClear",
            Description: "获取或设置是否显示清除按钮",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "DisplayDelete",
            Description: "获取或设置是否显示删除按钮",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {
            Name: "DisplayExport",
            Description: "获取或设置是否显示导出按钮",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "DisplayImport",
            Description: "获取或设置是否显示导入按钮",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "DisplayInsertRow",
            Description: "获取或设置是否显示插入行按钮",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "DefaultRowCount",
            Description: "获取或设置显示默认行总数",
            DefaultValue: 1,
            ValueRange: null
        }, {
            Name: "DisplaySequenceNo",
            Description: "获取或设置是否显示序号行",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {
            Name: "DisplaySummary",
            Description: "获取或设置是否显示汇总行",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {
            Name: "VirtualPaging",
            Description: "获取或设置是否分页加载",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "AlternatingRowStyle",
            Description: "获取或设置奇数行样式,如：background-color:#ccc",
            DefaultValue: "",
            ValueRange: null
        }],
        DesignEvents: [{
            Name: "OnPreAdd",
            Description: "获取或设置添加行之前的事件",
            DefaultValue: "",
            ValueRange: null
        }, {Name: "OnAdded", Description: "获取或设置添加行后的事件", DefaultValue: "", ValueRange: null}, {
            Name: "OnEditorSaving",
            Description: "获取或设置子表行的保存事件",
            DefaultValue: "",
            ValueRange: null
        }, {Name: "OnPreRemove", Description: "获取或设置删除行之前的事件", DefaultValue: "", ValueRange: null}, {
            Name: "OnRemoved",
            Description: "获取或设置删除行后的事件",
            DefaultValue: "",
            ValueRange: null
        }, {Name: "OnRendered", Description: "获取或设置控件初始化完成后事件", DefaultValue: "", ValueRange: null}]
    },
    SheetCountLabel: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "StatType",
            Description: "获取或设置控件统计的方式",
            DefaultValue: "SUM",
            ValueRange: ["NONE", "SUM", "AVG", "MAX", "MIN"]
        }, {Name: "FormatRule", Description: "获取或设置控件的格式化规则,如{0：C2}", DefaultValue: "", ValueRange: null}]
    },
    SheetHyperLink: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "NavigateUrl",
            Description: "获取或设置链接的URL",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "NavigateUrlDataField",
            Description: "获取或设置链接URL绑定的数据项值",
            DefaultValue: "",
            ValueRange: null
        }, {Name: "Text", Description: "获取或设置链接显示的文本", DefaultValue: "", ValueRange: null}, {
            Name: "TextDataField",
            Description: "获取或设置显示链接文本的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }], DesignEvents: []
    },
    SheetInstancePrioritySelector: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DefaultValue",
            Description: "获取或设置默认选定的值",
            DefaultValue: "Normal",
            ValueRange: ["High", "Normal", "Low"]
        }], DesignEvents: [{Name: "OnChange", Description: "获取或设置控件的点击事件"}]
    },
    SheetLabel: {
        BindTypeEnum: {OnlyVisiable: "onlyvisiable", OnlyData: "onlydata"},
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "BindType",
            Description: "获取或设置控件绑定的方式",
            DefaultValue: "OnlyVisiable",
            ValueRange: ["OnlyVisiable", "OnlyData"]
        }, {
            Name: "ComputationRule",
            Description: "获取或设置控件的计算规则",
            DefaultValue: "",
            ValueRange: null
        }, {Name: "DisplayRule", Description: "获取或设置控件的显示规则", DefaultValue: "", ValueRange: null}],
        DesignEvents: [{Name: "OnClick", Description: "设置控件的点击事件"}]
    },
    SheetOffice: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "PDFDataField",
            Description: "获取或设置绑定的PDF文件数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "Template",
            Description: "获取或设置文档的模板路径",
            DefaultValue: "Office/Template.doc",
            ValueRange: null
        }, {
            Name: "SignType",
            Description: "获取或设置印章类型(服务器/EKEY)",
            DefaultValue: "Server",
            ValueRange: ["Server", "EKEY"]
        }, {Name: "SignUrl", Description: "获取或设置(服务器)印章URL", DefaultValue: "", ValueRange: null}, {
            Name: "SignBookmark",
            Description: "获取或设置印章位置书签",
            DefaultValue: "SignDate",
            ValueRange: null
        }, {Name: "SignLeft", Description: "获取或设置印章位置相对书签的水平位移", DefaultValue: "0", ValueRange: null}, {
            Name: "SignTop",
            Description: "获取或设置印章位置相对书签的垂直位移",
            DefaultValue: "0",
            ValueRange: null
        }, {
            Name: "OfficeHeight",
            Description: "获取或设置Office控件的Height值",
            DefaultValue: "800px",
            ValueRange: null
        }, {
            Name: "OfficeWidth",
            Description: "获取或设置Office控件的OfficeWidth值",
            DefaultValue: "800px",
            ValueRange: null
        }, {
            Name: "RedTemplate",
            Description: "获取或设置套用模板的URL",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "BookmartMapping",
            Description: "获取或设置套用模板书签与数据项映射关系",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "CABPath",
            Description: "获取或设置CABPath包所在的路径",
            DefaultValue: "officecontrol.cab",
            ValueRange: null
        }, {
            Name: "ClassID",
            Description: "获取或设置绑定的NTKO给定的ClassID",
            DefaultValue: "A39F1330-3322-4a1d-9BF0-0BA2BB90E970",
            ValueRange: null
        }, {
            Name: "ProductVersion",
            Description: "获取或设置绑定的NTKO给定的Version",
            DefaultValue: "5,0,1,6",
            ValueRange: null
        }, {
            Name: "ProductCaption",
            Description: "获取或设置绑定的NTKO给定的ProductCaption",
            DefaultValue: "",
            ValueRange: null
        }, {Name: "ProductKey", Description: "获取或设置绑定的NTKO给定的ProductKey", DefaultValue: "", ValueRange: null}],
        DesignEvents: [{Name: "OnTemplate", Description: "设置文档控件的模板套用事件"}, {
            Name: "OnSign",
            Description: "设置文档控件加盖签章的方法"
        }]
    },
    SheetRadioButtonList: {
        RepeatDirectionEnum: {OnlyVisiable: "horizontal", All: "vertical"},
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DefaultItems",
            Description: "获取或设置控件的显示项",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DefaultSelected",
            Description: "获取或设置是否默认选中状态",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {
            Name: "DisplayRule",
            Description: "获取或设置控件的显示规则。",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "MasterDataCategory",
            Description: "获取或设置绑定的数据字典类型名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "RepeatColumns",
            Description: "获取或设置要在每行显示的列数。",
            DefaultValue: 5,
            ValueRange: null
        }, {
            Name: "RepeatDirection",
            Description: "获取或设置组中单选按钮的显示方向。",
            DefaultValue: "Horizontal",
            ValueRange: ["Horizontal", "Vertical"]
        }, {
            Name: "SelectedValue",
            Description: "获取或设置控件选中的值",
            DefaultValue: "",
            ValueRange: null
        }, {Name: "VaildationRule", Description: "获取或设置控件的验证规则，为True时必填!", DefaultValue: "", ValueRange: null}],
        DesignEvents: [{Name: "OnChange", Description: "获取或设置数据改变时执行脚本。"}]
    },
    SheetRichTextBox: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "AutoTrim",
            Description: "获取或设置是否自动去除前后空格",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {Name: "DefaultValue", Description: "获取或设置控件的默认值", DefaultValue: "", ValueRange: null}, {
            Name: "DisplayRule",
            Description: "获取或设置控件的显示规则",
            DefaultValue: "",
            ValueRange: null
        }, {Name: "PlaceHolder", Description: "获取或设置控件的水印文本", DefaultValue: "", ValueRange: null}, {
            Name: "RichTextBox",
            Description: "获取或设置是否使用富文本框进行展现",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {Name: "ToolTip", Description: "获取或设置显示的提示信息", DefaultValue: "", ValueRange: null}, {
            Name: "VaildationRule",
            Description: "获取或设置控件的验证规则",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "PopupWindow",
            Description: "获取或设置是否支持开窗查询",
            DefaultValue: "None",
            ValueRange: ["None", "PopupWindow", "Dropdown"]
        }, {
            Name: "DisplayText",
            Description: "获取或设置开窗查询文本",
            DefaultValue: "选择",
            ValueRange: null
        }, {
            Name: "PopupHeight",
            Description: "获取或设置开窗查询高度",
            DefaultValue: "400px",
            ValueRange: null
        }, {
            Name: "PopupWidth",
            Description: "获取或设置开窗查询宽度",
            DefaultValue: "600px",
            ValueRange: null
        }, {
            Name: "SchemaCode",
            Description: "获取或设置文本框开窗查询绑定的业务对象编码",
            DefaultValue: "",
            ValueRange: null,
            Popup: "SheetTextBoxSetting",
            Height: 450,
            Width: 550
        }, {
            Name: "QueryCode",
            Description: "获取或设置文本框开窗查询绑定的查询编码",
            DefaultValue: "",
            ValueRange: null,
            Popup: "SheetTextBoxSetting",
            Height: 450,
            Width: 550
        }, {
            Name: "InputMappings",
            Description: "获取或设置开窗查询输入参数条件，例&quot;数据项1:查询字段1,数据项2:查询字段2&quot;",
            DefaultValue: "",
            ValueRange: null,
            Popup: "SheetTextBoxSetting",
            Height: 450,
            Width: 550
        }, {
            Name: "OutputMappings",
            Description: "获取或设置开窗查询输出关系映射，例&quot;数据项1:查询字段1,数据项2:查询字段2&quot;",
            DefaultValue: "",
            ValueRange: null,
            Popup: "SheetTextBoxSetting",
            Height: 450,
            Width: 550
        }, {
            Name: "ViewInNewContainer",
            Description: "获取或设置在移动端是否显示到新窗口",
            DefaultValue: false,
            ValueRange: [true, false]
        }], DesignEvents: []
    },
    SheetTextBox: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "ComputationRule",
            Description: "获取或设置控件的计算规则",
            DefaultValue: "",
            ValueRange: null,
            Popup: "ComputationRule",
            Height: 390,
            Width: 490
        }, {Name: "DefaultValue", Description: "获取或设置控件的默认值", DefaultValue: "", ValueRange: null}, {
            Name: "DisplayRule",
            Description: "获取或设置控件的显示规则",
            DefaultValue: "",
            ValueRange: null,
            RichProperty: true
        }, {
            Name: "FormatRule",
            Description: "获取或设置控件的格式化规则,如{0：C2}",
            DefaultValue: "",
            ValueRange: null
        }, {Name: "PlaceHolder", Description: "获取或设置控件的水印文本", DefaultValue: "", ValueRange: null}, {
            Name: "ToolTip",
            Description: "获取或设置显示的提示信息",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "RegularExpression",
            Description: "获取或设置控件的正则表达式规则",
            DefaultValue: "",
            ValueRange: null,
            Popup: "SheetTextBoxRegular",
            Height: 450,
            Width: 540
        }, {
            Name: "RegularInvalidText",
            Description: "获取或设置验证失败时显示的文本",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "VaildationRule",
            Description: "获取或设置控件的验证表达式，为True时必填!",
            DefaultValue: "",
            ValueRange: null,
            RichProperty: true
        }, {
            Name: "PopupWindow",
            Description: "获取或设置是否支持开窗查询",
            DefaultValue: "None",
            ValueRange: ["None", "PopupWindow", "Dropdown"]
        }, {
            Name: "DisplayText",
            Description: "获取或设置开窗查询文本",
            DefaultValue: "选择",
            ValueRange: null
        }, {
            Name: "PopupHeight",
            Description: "获取或设置开窗查询高度",
            DefaultValue: "400px",
            ValueRange: null
        }, {
            Name: "PopupWidth",
            Description: "获取或设置开窗查询宽度",
            DefaultValue: "600px",
            ValueRange: null
        }, {
            Name: "SchemaCode",
            Description: "获取或设置文本框开窗查询绑定的业务对象编码",
            DefaultValue: "",
            ValueRange: null,
            Popup: "SheetTextBoxSetting",
            Height: 450,
            Width: 550
        }, {
            Name: "QueryCode",
            Description: "获取或设置文本框开窗查询绑定的查询编码",
            DefaultValue: "",
            ValueRange: null,
            Popup: "SheetTextBoxSetting",
            Height: 450,
            Width: 550
        }, {
            Name: "InputMappings",
            Description: "获取或设置开窗查询输入参数条件，例&quot;数据项1:查询字段1,数据项2:查询字段2&quot;",
            DefaultValue: "",
            ValueRange: null,
            Popup: "SheetTextBoxSetting",
            Height: 450,
            Width: 550
        }, {
            Name: "OutputMappings",
            Description: "获取或设置开窗查询输出关系映射，例&quot;数据项1:查询字段1,数据项2:查询字段2&quot;",
            DefaultValue: "",
            ValueRange: null,
            Popup: "SheetTextBoxSetting",
            Height: 450,
            Width: 550
        }, {
            Name: "ViewInNewContainer",
            Description: "获取或设置在移动端是否显示到新窗口",
            DefaultValue: false,
            ValueRange: [true, false]
        }],
        DesignEvents: [{Name: "OnChange", Description: "获取或设置文本框值改变事件"}, {
            Name: "OnFocus",
            Description: "获取或设置文本框获取焦点时事件"
        }, {Name: "OnKeyDown", Description: "获取或设置键盘摁下事件"}, {Name: "OnKeyUp", Description: "获取或设置键盘回弹事件"}]
    },
    SheetTime: {
        TimeModeEnum: {
            "OnlyDate": "OnlyDate",
            "SimplifiedTime": "SimplifiedTime",
            "FullTime": "FullTime",
            "OnlyTime": "OnlyTime"
        },
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DefaultValue",
            Description: "获取或设置当前控件的默认值",
            DefaultValue: "CurrentTime",
            ValueRange: null
        }, {
            Name: "TimeMode",
            Description: "获取或设置日期控件的显示模式",
            DefaultValue: "OnlyDate",
            ValueRange: ["OnlyDate", "FullTime", "SimplifiedTime", "OnlyTime"]
        }, {
            Name: "MinValue",
            Description: "获取或设置日期控件显示的最小值",
            DefaultValue: "2010-01-01 00:00:00",
            ValueRange: null
        }, {
            Name: "MaxValue",
            Description: "获取或设置日期控件显示的最大值",
            DefaultValue: "2050-12-31 23:59:59",
            ValueRange: null
        }, {
            Name: "WdatePickerJson",
            Description: "获取或设置日期控件的显示JSON字符串(参考WdatePicker控件)",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "ViewInNewContainer",
            Description: "获取或设置在移动端是否显示到新窗口",
            DefaultValue: false,
            ValueRange: [true, false]
        }],
        DesignEvents: [{Name: "OnChange", Description: "获取或设置日期选定值变更后事件"}]
    },
    SheetUser: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "DefaultValue",
            Description: "获取或设置选人控件绑定的默认值",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "PlaceHolder",
            Description: "获取或设置控件的水印文本",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "SegmentVisible",
            Description: "获取或设置是否选择【组织群】",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "OrgUnitVisible",
            Description: "获取或设置是否选择【组织单元】",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "GroupVisible",
            Description: "获取或设置是否选择【用户组】",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "PostVisible",
            Description: "获取或设置是否选择【岗位】",
            DefaultValue: false,
            ValueRange: [true, false]
        }, {
            Name: "UserVisible",
            Description: "获取或设置是否选择【用户】",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {Name: "RootUnit", Description: "获取或设置根节点显示的组织节点编码", DefaultValue: "", ValueRange: null}, {
            Name: "Recursive",
            Description: "获取或设置是否递归显示所有子节点",
            DefaultValue: true,
            ValueRange: [true, false]
        }, {Name: "VisibleUnits", Description: "获取需要显示的组织单元编码", DefaultValue: "", ValueRange: null}, {
            Name: "RoleName",
            Description: "获取或设置显示指定的组名称中的用户",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "OrgJobCode",
            Description: "获取或设置显示指定的职务编码中的用户",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "OrgPostCode",
            Description: "获取或设置显示指定的岗位编码中的用户",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "OrgCode",
            Description: "获取或设置只显示指定编码的组织编码，多个以,分隔",
            DefaultValue: "",
            ValueRange: null
        }, {
            Name: "MappingControls",
            Description: "获取控件和属性映射关系",
            DefaultValue: "",
            ValueRange: null,
            Popup: "SheetUserSetting",
            Height: 430,
            Width: 520
        }], DesignEvents: [{Name: "OnChange", Description: "获取或设置控件的选人变更事件"}]
    },
    SheetTimeSpan: {
        DesignProperties: [{
            Name: "DataField",
            Description: "获取或设置控件绑定的数据项名称",
            DefaultValue: "",
            ValueRange: null
        }], DesignEvents: [{Name: "OnChange", Description: "获取或设置日期选定值变更后事件"}]
    }
};
var SheetLanguages = {
    Current: {}, zh_cn: {
        Uploading: "未上传完!",
        Add: "添加",
        Upload: "上传",
        All: "全部",
        OK: "确定",
        Clear: "清除",
        Remove: "删除",
        Export: "导出",
        Close: "关闭",
        Import: "导入",
        Cancel: "取消",
        DragUpload: "点击上传或拖拽文件到此上传",
        Loading: "请稍候...",
        Doing: "正在处理",
        ConfirmRemove: "确认删除？",
        FileExtError: "文件格式不对",
        OverMaxLength: "超出限制文件上传的大小",
        Download: "下载",
        UploadError: "上传失败",
        DataItemNotExists: "数据项不存在",
        MyComment: "我的意见",
        Today: "今天",
        Notice: "提示",
        Delegant: "委托",
        SelectComment: "请选择常用意见",
        FrequentlyUsedComment: "设为常用",
        SelectSign: "请选择签章",
        Records: "条记录",
        BookmarkNotExists: "Word 模板中不存在名称为 {{0}} 的书签!",
        PdfNotSave: "不能执行保存,没有编辑文档或者没有安装PDF虚拟打印机!",
        IE: "请使用IE浏览器，并安装第三方插件！",
        CreatePDF: "生成PDF",
        ViewPDF: "查看PDF",
        AddESP: "加盖印章",
        AddTemplate: "套用模板",
        EnterInteger: "请输入一个有效的整数",
        EnterNumber: "请输入一个有效的数值",
        Day: "天",
        Hour: "小时",
        Minute: "分钟",
        Second: "秒",
        SelectUser: "请选择参与者",
        ConfirmCancelInstance: "确定执行取消流程操作?",
        Disagree: "不同意",
        Agree: "同意",
        Search: "搜索",
        ConfirmFinishInstance: "确定执行结束流程操作?",
        SelectForwardUser: "请选择转发人",
        SelectAssistUser: "请选择协办接收人",
        AssistRemind: "用户提交意见或取消协助任务时接收邮件提醒",
        ConsultRemind: "用户提交意见时接收邮件提醒.",
        SelectConsultUser: "请选择要征询意见的人",
        SelectCirculateUser: "请选择要传阅的人员",
        AllowCirculate: "允许再传阅给其他人",
        SelectSignUser: "请选择要加签的人",
        ConfrimClose: "确定要关闭页面?",
        ConfirmReterive: "确定执行取回流程操作",
        SelectFromOrg: "从组织架构选择",
        SearchNone: "没搜索到组织",
        Saving: "正在保存...",
        Sumiting: "正在提交...",
        Rejecting: "正在驳回...",
        Finishing: "正在结束流程...",
        Retrieving: "正在取回流程...",
        ConfirmDo: "确定执行",
        Operation: "操作"
    }, en_us: {
        Uploading: "upload not complete!",
        Add: "Add",
        All: "All",
        OK: "OK",
        Cancel: "Cancel",
        Search: "Search",
        Close: "Close",
        Clear: "Clear",
        Upload: "Upload",
        Remove: "Remove",
        Export: "Export",
        Import: "Import",
        DragUpload: "Click or drag file to here for upload",
        Loading: "Load...",
        Doing: "Load",
        ConfirmRemove: "Confrim remove this?",
        FileExtError: "File extension error.",
        OverMaxLength: "File size exceeds the limit.",
        Download: "Download",
        UploadError: "Upload error",
        DataItemNotExists: "dataitem not exists",
        MyComment: "My comment",
        Today: "Today",
        Notice: "Notice",
        Delegant: "Delegant",
        SelectComment: "Please select comment",
        FrequentlyUsedComment: "Frequently",
        SelectSign: "Please select sign",
        Records: "records",
        BookmarkNotExists: "Bookmark {{0}} is not exists in this word template!",
        PdfNotSave: "Can't save,does not have edit document or pdf creator not install!",
        IE: "Please use the ie browser!",
        CreatePDF: "Create PDF",
        ViewPDF: "View PDF",
        AddESP: "Add Sign",
        AddTemplate: "Add Template",
        EnterInteger: "Please enter a valid integer",
        EnterNumber: "Please enter a valid number",
        Day: "Day",
        Hour: "Hour",
        Minute: "Minute",
        Second: "Second",
        SelectUser: "Please select user",
        ConfirmCancelInstance: "Confirm cancel this instance?",
        Disagree: "Disagree",
        Agree: "Agree",
        ConfirmFinishInstance: "Confirm finish this instance?",
        SelectForwardUser: "Please select forward user",
        SelectAssistUser: "Please select assist user",
        AssistRemind: "Receive email after assist user submit or cancel.",
        ConsultRemind: "Receive email after consult user submit.",
        SelectConsultUser: "Please select consult user",
        SelectCirculateUser: "Please select circulate user",
        AllowCirculate: "Allow recirculate to other",
        SelectSignUser: "Please add an approve user",
        ConfrimClose: "Confirm close this page?",
        ConfirmReterive: "Confirm retrieve this instance?",
        SelectFromOrg: "Select from organization",
        SearchNone: "No search results",
        Saving: "Saving...",
        Sumiting: "Submiting...",
        Rejecting: "Rejecting...",
        Finishing: "Finishing...",
        Retrieving: "Retrieving...",
        ConfirmDo: "Confirm to do ",
        Operation: ""
    }
};
var MvcSheetUIGlobalString = {"RegularExpression_errorMessage": "绑定的正则表达式不合法:"};
//$.ajax({ type: "GET", url: _PORTALROOT_GLOBAL + "/Ajax/GlobalHandler.ashx?Code=RegularExpression_errorMessage", async: false, dataType: "json", success: function (A) { if (A.IsSuccess) { MvcSheetUIGlobalString = A.TextObj } } });
(function ($) {
    Function.prototype.Inherit = function (parent, overrides) {
        if (typeof parent != "function") {
            return this
        }
        this.Base = parent.prototype;
        this.Base.constructor = parent;
        var f = function () {
        };
        f.prototype = parent.prototype;
        this.prototype = new f();
        this.prototype.constructor = this;
        if (overrides) {
            $.extend(this.prototype, overrides)
        }
    };
    String.prototype = {
        trim: function () {
            return this.replace(/[ ]/g, "")
        }
    };
    $.fn.SheetUIManager = function (rowNum) {
        var manager;
        if ($(this).data($.MvcSheetUI.SheetIDKey)) {
            return $.MvcSheetUI.ControlManagers[$(this).data($.MvcSheetUI.SheetIDKey)]
        }
        var datafield = $(this).data($.MvcSheetUI.DataFieldKey.toLowerCase());
        if (datafield == undefined) {
            return manager
        }
        var dataitem = $.MvcSheetUI.GetSheetDataItem(datafield, rowNum);
        if (dataitem == undefined) {
            return manager
        }
        $(this).each(function () {
            if (manager != null) {
                return
            }
            switch (this.tagName.toLowerCase()) {
                case "label":
                case "span":
                    manager = $(this).SheetLabel(dataitem);
                    break;
                case "input":
                    switch (this.type) {
                        case "text":
                            if (dataitem.L == $.MvcSheetUI.LogicType.DateTime) {
                                manager = $(this).SheetTime(dataitem)
                            } else {
                                manager = $(this).SheetTextBox(dataitem)
                            }
                            break;
                        case "checkbox":
                            $(this).SheetCheckbox(dataitem);
                            break;
                        case "radio":
                            manager = $(this).SheetRadioButtonList(dataitem);
                            break;
                        default:
                            break
                    }
                case "textarea":
                    manager = $(this).SheetRichTextBox(dataitem);
                    break;
                case "div":
                    var controlType = $(this).data("type");
                    if (controlType) {
                        if (controlType.toLowerCase() == "sheetoffice" && !(!!window.ActiveXObject || "ActiveXObject" in window)) {
                            controlType = "SheetAttachment"
                        }
                        manager = $.MvcSheetUI.Run.call($(this), controlType, [dataitem])
                    } else {
                        if (dataitem) {
                            if (dataitem.L == $.MvcSheetUI.LogicType.SingleParticipant || dataitem.L == $.MvcSheetUI.LogicType.MultiParticipant) {
                                manager = $(this).SheetUser(dataitem)
                            } else {
                                if (dataitem.L == $.MvcSheetUI.LogicType.Attachment) {
                                    manager = $(this).SheetAttachment(dataitem)
                                } else {
                                    if (dataitem.L == $.MvcSheetUI.LogicType.Comment) {
                                        manager = $(this).SheetComment(dataitem)
                                    } else {
                                        if (dataitem.L == $.MvcSheetUI.LogicType.TimeSpan) {
                                            manager = $(this).SheetTimeSpan(dataitem)
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;
                case "table":
                    if (dataitem.L == $.MvcSheetUI.LogicType.BizObjectArray || dataitem.L == $.MvcSheetUI.LogicType.BizObject) {
                        manager = $(this).SheetGridView(dataitem)
                    }
                    break;
                case "select":
                    if ($(this).data("type") == "SheetInstancePrioritySelector") {
                        manager = $(this).SheetInstancePrioritySelector(dataitem)
                    } else {
                        manager = $(this).SheetDropDownList(dataitem)
                    }
                    break;
                case "a":
                    manager = $(this).SheetHyperLink(dataitem);
                    break
            }
        });
        return manager
    }, $.MvcSheetUI = {
        Version: "V1.0",
        SheetIDKey: "sheetid",
        PreDataKey: "data-",
        DataFieldKey: "DataField",
        ComputationRule: "ComputationRule",
        SheetControlKey: "SheetControl",
        Type: "Type",
        PortalRoot: window.localStorage.getItem("H3.PortalRoot") ? window.localStorage.getItem("H3.PortalRoot") : "/Portal",
        SheetInfo: null,
        MvcRuntime: null,
        Priority: "Unspecified",
        HiddenFields: {},
        Loading: false,
        Controls: {},
        ManagerCount: 0,
        ControlManagers: {},
        Css: {
            inputMouseOut: "inputMouseOut",
            inputMouseMove: "inputMouseMove",
            inputMouseEnter: "inputMouseEnter",
            inputError: "inputError",
            InvalidText: "InvalidText",
            Readonly: "Readonly"
        },
        ValidateText: "表单验证不通过!",
        Run: function (control, args) {
            var p = $.ControlsOptions.GetDefaultOptions(control);
            if (args.length > 0) {
                $.extend(p, {DataItem: args[0]});
                $.extend(p, args[0])
            }
            var currentSheetIDKey = 0;
            var isOneControl = 0;
            this.each(function () {
                if (!$(this).data($.MvcSheetUI.SheetIDKey)) {
                    isOneControl++;
                    $.MvcSheetUI.ManagerCount++;
                    currentSheetIDKey = $.MvcSheetUI.SheetIDKey + "-" + $.MvcSheetUI.ManagerCount.toString();
                    p[$.MvcSheetUI.DataFieldKey] = $(this).data($.MvcSheetUI.DataFieldKey.toLowerCase());
                    p[$.MvcSheetUI.Type] = control;
                    $(this).data($.MvcSheetUI.SheetIDKey, currentSheetIDKey);
                    $.MvcSheetUI.ControlManagers[$(this).data($.MvcSheetUI.SheetIDKey)] = new $.MvcSheetUI.Controls[control](this, p, $.MvcSheetUI.SheetInfo)
                } else {
                    isOneControl = 1;
                    return
                }
            });
            if (isOneControl == 1) {
                return $.MvcSheetUI.ControlManagers[$(this).data($.MvcSheetUI.SheetIDKey)]
            }
        },
        GetSheetDataItem: function (datafield, rowNum) {
            var DataItems = $.MvcSheetUI.SheetInfo.BizObject.DataItems;
            if (datafield == undefined) {
                return null
            }
            var dataitem = null;
            if (datafield.indexOf(".") > -1 && DataItems[datafield.split(".")[0]] && DataItems[datafield.split(".")[0]].L == $.MvcSheetUI.LogicType.BizObject) {
                if (DataItems[datafield.split(".")[0]].V.DataItems) {
                    dataitem = DataItems[datafield.split(".")[0]].V.DataItems[datafield];
                    $.extend(dataitem, {BizObjectID: DataItems[datafield.split(".")[0]].V.DataItems[datafield.split(".")[0] + ".ObjectID"].V});
                    $.extend(dataitem, {RowNum: 1});
                    return DataItems[datafield.split(".")[0]].V.DataItems[datafield]
                }
            } else {
                if (rowNum != undefined && rowNum > 0 && datafield.indexOf(".") > -1) {
                    rowNum = rowNum - 1;
                    var parentdatafield = datafield.split(".")[0];
                    var DetailVale = DataItems[parentdatafield].V;
                    if (DetailVale.R && DetailVale.R.length > rowNum) {
                        dataitem = DetailVale.R[rowNum].DataItems[datafield];
                        $.extend(dataitem, {BizObjectID: DetailVale.R[rowNum].DataItems[parentdatafield + ".ObjectID"].V})
                    } else {
                        var DefaultRow = DetailVale.T;
                        if (!DefaultRow) {
                            DefaultRow = this.GetElement(parentdatafield).SheetUIManager().DefaultRow
                        }
                        if (DefaultRow) {
                            dataitem = DefaultRow.DataItems[datafield]
                        }
                    }
                    $.extend(dataitem, {RowNum: rowNum + 1})
                } else {
                    dataitem = DataItems[datafield];
                    $.extend(dataitem, {RowNum: 0})
                }
            }
            return dataitem
        },
        SaveSheetData: function (actionName) {
            var SheetData = {};
            for (var control in this.ControlManagers) {
                var controlManager = this.ControlManagers[control];
                if (controlManager.Type && controlManager.Type == "SheetHiddenField") {
                    $.extend(SheetData, controlManager.SaveDataField(actionName))
                } else {
                    if (!$.isFunction(controlManager.SaveDataField) || controlManager.DataField == undefined || controlManager.DataField.indexOf(".") != -1) {
                        continue
                    }
                    $.extend(SheetData, controlManager.SaveDataField(actionName))
                }
            }
            return SheetData
        },
        GetElement: function (datafiled, rownum) {
            var element;
            var row = rownum == undefined ? 0 : rownum;
            if (datafiled.indexOf("#") == 0) {
                element = $(datafiled)
            } else {
                if (datafiled.indexOf(".") > -1) {
                    if (rownum == undefined) {
                        row = 1
                    }
                    element = $("[" + this.PreDataKey + this.DataFieldKey.toLowerCase() + "='" + datafiled + "'][data-row=" + row + "]")
                } else {
                    $("[" + this.PreDataKey + this.DataFieldKey.toLowerCase() + "='" + datafiled + "']").each(function () {
                        var flag = true;
                        if (this.tagName.toLowerCase() == "td") {
                            flag = false
                        }
                        if (flag) {
                            if ((this.tagName.toLowerCase() == "label" || this.tagName.toLowerCase() == "span") && $(this).attr("BindType") == "All") {
                                element = $(this)
                            } else {
                                element = $(this)
                            }
                        }
                    })
                }
            }
            return element
        },
        GetControlValue: function (datafiled, rownum) {
            var control = this.GetElement(datafiled, rownum);
            if (control) {
                var manager = $(control).SheetUIManager();
                if (manager) {
                    return manager.GetValue()
                } else {
                    return null
                }
            } else {
                return null
            }
        },
        SetControlValue: function (datafiled, val, rownum) {
            var control = this.GetElement(datafiled, rownum);
            if (control) {
                var manager = $(control).SheetUIManager();
                if (manager) {
                    manager.SetValue(val)
                }
            }
        },
        Validate: function (actionControl, effective) {
            var flag = true;
            if (!effective) {
                effective = false
            }
            if (this.SheetInfo.IsMobile) {
                if ($(".SheetComment").find("textarea").length > 0 && !$.trim($(".SheetComment").find("textarea").val())) {
                    alert("请输入审核意见!");
                    return false
                }
            }
            if (actionControl.IsReject) {
                effective = true
            }
            for (var control in this.ControlManagers) {
                var controlManager = this.ControlManagers[control];
                if (!$.isFunction(controlManager.Validate)) {
                    continue
                }
                if (controlManager instanceof $.MvcSheetUI.Controls.SheetComment && actionControl.IsReject) {
                    if (!controlManager.Validate(false) && flag) {
                        controlManager.SetFocus();
                        flag = false
                    }
                } else {
                    if (!controlManager.Validate(effective) && flag) {
                        controlManager.SetFocus();
                        flag = false
                    }
                }
            }
            if (!flag) {
                alert(this.ValidateText)
            }
            return flag
        }
    };
    $.ControlsOptions = {
        GetDefaultOptions: function (control) {
            var p = {};
            var options = SheetControls[control] || this[control];
            for (var key in options) {
                if (options[key].constructor == String || options[key].constructor == Number || options[key].constructor == Object) {
                    p[key] = options[key] || ""
                } else {
                    if (options[key].constructor == Array) {
                        for (var i = 0; i < options[key].length; ++i) {
                            p[options[key][i].Name] = options[key][i].DefaultValue || ""
                        }
                    }
                }
            }
            return p
        }
    };
    $.MvcSheetUI.SheetMode = {
        Unspecified: -1,
        Work: 1,
        View: 2,
        Originate: 3,
        Print: 4
    }, $.MvcSheetUI.LogicType = {
        Unspecified: -1,
        BoolArray: 0,
        Bool: 1,
        DateTimeArray: 4,
        DateTime: 5,
        DoubleArray: 6,
        Double: 7,
        IntArray: 8,
        Int: 9,
        LongArray: 10,
        Long: 11,
        StringArray: 12,
        String: 13,
        ShortString: 14,
        HyperLink: 16,
        Comment: 17,
        ByteArray: 20,
        Attachment: 24,
        TimeSpan: 25,
        SingleParticipant: 26,
        MultiParticipant: 27,
        Html: 30,
        Object: 31,
        Xml: 32,
        Guid: 33,
        GuidArray: 34,
        Decimal: 35,
        DecimalArray: 36,
        BizObject: 40,
        BizObjectArray: 41,
        BizStructure: 42,
        BizStructureArray: 43
    }, $.MvcSheetUI.UnitType = {
        Unspecified: 1 | 16 | 2 | 4 | 8 | 32 | 64,
        Company: 1,
        OrganizationUnit: 2,
        Group: 4,
        User: 8,
        Segment: 16,
        Post: 32,
        Staff: 64
    };
    $.MvcSheetUI.QueryString = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = decodeURI(window.location.search.substr(1)).match(reg);
        if (r != null) {
            return decodeURI(r[2])
        }
        return null
    };
    $.MvcSheetUI.NewGuid = function () {
        var getStr = function (len) {
            if (len > 12) {
                len = 12
            }
            return Math.floor(Math.random() * 100000000000000).toString("16").substring(0, len)
        };
        return (getStr(8) + "-" + getStr(4) + "-4" + getStr(3) + "-" + getStr(4) + "-" + getStr(12)).trim()
    };
    $.SheetModal = function (title, target, actions) {
        this.IsShow = false;
        this.ShowModal(title, target, actions)
    };
    $.SheetModal.prototype = {
        ShowModal: function (title, target, actions) {
            this.ID = $.MvcSheetUI.NewGuid();
            this.Modal = $('<div class="modal fade" id="' + this.ID + '" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>');
            var modalDialog = $('<div class="modal-dialog"></div>');
            var modalContent = $('<div class="modal-content"></div>');
            var modalHeader = $('<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>');
            this.ModalTitle = $('<h4 class="modal-title" id="myModalLabel"></h4>');
            this.ModalBody = $('<div class="modal-body"></div>');
            this.ModalFooter = $('<div class="modal-footer"></div>');
            this.Modal.append(modalDialog);
            modalDialog.append(modalContent);
            modalContent.append(modalHeader);
            modalHeader.append(this.ModalTitle);
            modalContent.append(this.ModalBody);
            modalContent.append(this.ModalFooter);
            this.SetTile(title);
            this.SetBody(target);
            if (actions) {
                for (var i = 0; i < actions.length; i++) {
                    var btnJson = actions[i];
                    this.AddAction(btnJson)
                }
            }
            this.Show();
            this.Modal.on("hidden.bs.modal", this, function (e) {
                e.data.IsShow = false
            });
            return this
        }, SetTile: function (title) {
            this.ModalTitle.html(title)
        }, SetBody: function (target) {
            this.ModalBody.append($(target))
        }, AddAction: function (actionObject) {
            $.extend(actionObject, {ModalManager: this});
            var btn = $('<button type="button" class="btn">' + actionObject.Text + "</button>");
            if (actionObject.DoAction) {
                btn.unbind("click").bind("click", actionObject, function (e) {
                    e.data.DoAction.apply(e.data)
                })
            }
            this.ModalFooter.append(btn)
        }, Show: function () {
            if (this.IsShow) {
                return
            }
            this.IsShow = true;
            this.Modal.modal("show")
        }, Hide: function () {
            if (!this.IsShow) {
                return
            }
            this.IsShow = false;
            this.Modal.modal("hide")
        }
    };
    $.extend({
        LoadingMask: {
            Show: function (msg, isAlpha) {
                if ($.MvcSheetUI.QueryString("ismobile") == "true") {
                    return
                }
                if ($.SheetMask.IsShow) {
                    return
                }
                $.SheetMask.Show(isAlpha);
                this.MsgDiv = $("<div></div>");
                this.MsgDiv.append($("<img src='" + $.MvcSheetUI.PortalRoot + "/WFRes/_Content/themes/ligerUI/Aqua/images/common/bigloading.gif' />"));
                this.MsgDiv.append($('<span style="font-size: 18px;font-weight: bold;padding-left: 10px;">' + msg + "</span>"));
                this.MsgDiv.css("position", "fixed");
                this.MsgDiv.css("top", "42%");
                this.MsgDiv.css("left", "43%");
                this.MsgDiv.css("z-index", "9999");
                this.MsgDiv.appendTo($("body"))
            }, Hide: function () {
                if ($.MvcSheetUI.QueryString("ismobile") == "true") {
                    return
                }
                if ($.SheetMask.IsShow) {
                    $.SheetMask.Hide();
                    this.MsgDiv.remove()
                }
            }
        }, SheetMask: {
            IsShow: false, Show: function (isAlpha) {
                var opacity = 0.6;
                if (isAlpha != undefined && isAlpha == false) {
                    opacity = 1
                }
                if (this.IsShow) {
                    return
                }
                this.IsShow = true;
                this.ID = $.MvcSheetUI.NewGuid();
                this.Mask = $("<div></div>").attr("id", "SheetMask_" + this.ID);
                this.Mask.appendTo($("body"));
                this.Mask.css("position", "absolute");
                this.Mask.css("top", "0px");
                this.Mask.css("left", "0px");
                this.Mask.css("width", "100%");
                this.Mask.css("height", $("body").height() + 60);
                this.Mask.css("text-align", "center");
                this.Mask.css("z-index", "9999");
                this.Mask.css("background-color", "#ffffff");
                this.Mask.css("filter", "Alpha (opacity=1)");
                this.Mask.css("opacity", opacity);
                $("body").css("overflow", "hidden")
            }, Hide: function () {
                if (this.IsShow) {
                    this.IsShow = false;
                    this.Mask.remove();
                    $("body").css("overflow", "")
                }
            }
        }
    });
    $.MvcSheetUI.IControl = function (element, options, sheetInfo) {
        this.IsHtml5 = ((!!window.ActiveXObject || "ActiveXObject" in window) || typeof (Worker) != "undefined");
        this.SchemaCode = sheetInfo.SchemaCode;
        this.PortalRoot = $.MvcSheetUI.PortalRoot;
        this.Element = element;
        this.IsMobile = sheetInfo.IsMobile || ($.MvcSheetUI.QueryString("ismobile") == "true");
        this.Originate = $.MvcSheetUI.QueryString("Mode").toLowerCase() == "originate";
        this.Css = {
            inputMouseOut: $.MvcSheetUI.Css.inputMouseOut,
            inputMouseMove: $.MvcSheetUI.Css.inputMouseMove,
            inputMouseEnter: $.MvcSheetUI.Css.inputMouseEnter,
            inputError: $.MvcSheetUI.Css.inputError,
            InvalidText: $.MvcSheetUI.Css.InvalidText
        };
        this.ValidateResult = true;
        this.Options = options || {};
        this.SheetInfo = sheetInfo;
        this.ViewInNewContainer = true;
        this.Init();
        this.LogicType = this.L || $.MvcSheetUI.LogicType.ShortString;
        this.Visiable = this.IsMobile ? (this.O && this.O.indexOf("M") != -1) : (this.O && this.O.indexOf("V") != -1);
        this.Editable = this.O && this.O.indexOf("E") != -1;
        if ($.MvcSheetUI.QueryString("Mode").toLowerCase() == "print") {
            this.Editable = false
        }
        this.MobileContainer = null;
        this.FormatAction = "GetFormatValue";
        this.Required = this.O && this.O.indexOf("R") != -1;
        this.TrackVisiable = this.O && this.O.indexOf("T") != -1;
        $(this.Element).parent().attr("data-title", ($(this.Element).parent().prev().text() || "").trim());
        this.PreRender();
        if (this.IsMobile) {
            this.Mask = $("<span class='input-mask'></span>");
            if (!this.Visiable) {
                $(this.Element).parent().hide();
                $(this.Element).parent().prev().hide()
            }
            if (this.RenderMobile) {
                this.RenderMobile()
            }
        } else {
            this.Render()
        }
        this.Rendered();
        if (this.IsMobile) {
            if (!($(this.Element).is("label,span") && ($(this.Element).attr("bindtype") || "").toLowerCase() != "all") && this.Editable) {
                if (this.Validate(true, true)) {
                    $(this.Element).trigger("MobileValidateSucceed")
                } else {
                    $(this.Element).trigger("MobileValidateFaild")
                }
            }
        }
    };
    $.MvcSheetUI.IControl.prototype = {
        Init: function () {
            var g = this, p = this.Options;
            for (var key in p) {
                var elementkey = key.toLowerCase();
                if ($(g.Element).data(elementkey) != undefined) {
                    if (p[key].constructor == Boolean) {
                        p[key] = $(g.Element).data(elementkey).constructor == Boolean ? $(g.Element).data(elementkey) : ($(g.Element).data(elementkey).toString().toLowerCase() == "true" || $(g.Element).data(elementkey).toString().toLowerCase() == "1")
                    } else {
                        if (p[key].constructor == Number) {
                            p[key] = parseInt($(g.Element).data(elementkey))
                        } else {
                            p[key] = $(g.Element).data(elementkey).toString()
                        }
                    }
                }
            }
            var p = this.Options;
            for (var key in p) {
                this[key] = p[key]
            }
            $.MvcSheet.ControlInit.apply(this, [this.DataItem, this.SheetInfo])
        }, AddInvalidText: function (element, invalidText, cssChange) {
            var id = element.id || "";
            if (cssChange == null || cssChange) {
                $(element).addClass(this.Css.inputError)
            }
            if (!$(element).next().hasClass(this.Css.InvalidText)) {
                $('<label class="' + this.Css.InvalidText + '">' + invalidText + "</label>").insertAfter($(element))
            }
        }, RemoveInvalidText: function (element) {
            $(element).removeClass(this.Css.inputError);
            if ($(element).next().hasClass(this.Css.InvalidText)) {
                $(element).next().remove()
            }
        }, PreRender: function () {
            $.MvcSheet.ControlPreRender.apply(this, [this.DataItem, this.SheetInfo])
        }, Render: function () {
        }, RunScript: function (obj, script, args) {
            if (!script) {
                return
            }
            if ($.isFunction(script)) {
                script.apply(obj, args)
            } else {
                (new Function(script)).apply(obj, args)
            }
        }, RenderMobile: function () {
            this.Render();
            if (!this.Editable || !this.Visiable || ($(this.Element).is("label,span") && ($(this.Element).attr("bindtype") || "").toLowerCase() != "all")) {
                return
            }
            if (this.ViewInNewContainer) {
                this.MoveToMobileContainer(this.Element)
            } else {
                if ($(this.Element).is("select")) {
                    $(this.Element).attr("dir", "rtl")
                }
            }
        }, MoveToMobileContainer: function (_Editor) {
            _Element = _Editor || this.Element;
            var _Mask = this.Mask.text(this.GetText());
            _Mask.insertAfter(_Element);
            var _Parent = _Mask.parent();
            var _Title = _Parent.prev("div");
            var _EditPanel = $("<div class='panel'></div>");
            var _EditPanelID = $.uuid();
            _EditPanel.attr("data-title", _Title.text()).attr("data-footer", "none").attr("id", _EditPanelID);
            _EditPanel.appendTo("#content");
            _EditPanel.append(_Element);
            this.EditPanel = _EditPanel;
            this.EditPanelID = _EditPanelID;
            if (this instanceof $.MvcSheetUI.Controls.SheetUser) {
            } else {
                $(_Element).before('<div class="bannerTitle"></div>')
            }
            if ($(_Element).is("textarea")) {
                $(_Element).css("min-height", "120px")
            }
            var thatSheetControl = this;
            $(_Element).unbind("MobileValidateFaild").bind("MobileValidateFaild", function (e) {
                $(_Mask).addClass("error")
            });
            $(_Element).unbind("MobileValidateSucceed").bind("MobileValidateSucceed", function (e) {
                $(_Mask).removeClass("error")
            });
            $("#defaultHeader").find(".backButton").unbind("click.EditCompleted").bind("click.EditCompleted", thatSheetControl, function (e) {
                e.data.MobilePreBack.apply(e.data);
                if ($.ui.activeDiv.id != _EditPanelID) {
                    return
                }
                _Mask.text(thatSheetControl.GetText());
                if (thatSheetControl.Validate()) {
                    $(thatSheetControl.Element).trigger("MobileValidateSucceed")
                } else {
                    $(thatSheetControl.Element).trigger("MobileValidateFaild")
                }
            });
            var _LastTopTimeStamp = 0;
            var _thatElement = _Element;
            var _MobileEdit = function (et) {
                if (et.timeStamp - _LastTopTimeStamp < 2000) {
                    return
                }
                _LastTopTimeStamp = et.timeStamp;
                var _PrevTitle = $("#header").children("header").find("h1").text().trim();
                $.ui.loadContent(_EditPanelID);
                $.ui.setBackButtonVisibility(true);
                $("#defaultHeader").find(".backButton").unbind("click.EditCompleted").bind("click.EditCompleted", thatSheetControl, function (e) {
                    e.data.MobilePreBack.apply(e.data);
                    if ($.ui.activeDiv.id != _EditPanelID) {
                        return
                    }
                    _Mask.text(thatSheetControl.GetText());
                    if (thatSheetControl.Validate()) {
                        $(thatSheetControl.Element).trigger("MobileValidateSucceed")
                    } else {
                        $(thatSheetControl.Element).trigger("MobileValidateFaild")
                    }
                });
                $.ui.setBackButtonText("返回");
                setTimeout(function () {
                    if (!($(_thatElement).data("type") == "SheetTime" && $.os.isios7)) {
                        $(_thatElement).focus()
                    }
                    thatSheetControl.AfterMobileEditShow.apply(thatSheetControl)
                }, 500)
            };
            if (this.VaildationRule) {
                $(_Element).unbind("change.MobileValidate").bind("change.MobileValidate", function () {
                    if (thatSheetControl.Validate()) {
                        $(thatSheetControl.Element).trigger("MobileValidateSucceed")
                    } else {
                        $(thatSheetControl.Element).trigger("MobileValidateFaild")
                    }
                })
            }
            if (this.ComputationRule) {
                $(_Element).unbind("change.MobileMaskText").bind("change.MobileMaskText", function (e) {
                    _Mask.text(thatSheetControl.GetText())
                })
            }
            if ($(this.Element).data("type") == "SheetDropDownList") {
                $(_Element).unbind("change.DropDownList").bind("change.DropDownList", function (e) {
                    _Mask.text(thatSheetControl.GetText())
                })
            }
            var viewable = true;
            if ((this instanceof $.MvcSheetUI.Controls.SheetAttachment) && !this.Editable && this.V && this.V.length == 0) {
                viewable = false;
                $(_Mask).removeClass("input-mask")
            }
            if (viewable) {
                $(_Parent).unbind("click.MobileEditable").bind("click.MobileEditable", function (et) {
                    _MobileEdit(et)
                }).unbind("click.MobileEditable").bind("click.MobileEditable", function (et) {
                    _MobileEdit(et)
                });
                $(_Title).unbind("click.MobileEditable").bind("click.MobileEditable", function (et) {
                    _MobileEdit(et)
                }).unbind("click.MobileEditable").bind("click.MobileEditable", function (et) {
                    _MobileEdit(et)
                })
            }
            return _EditPanelID
        }, Rendered: function () {
            $.MvcSheet.ControlRendered.apply(this, [this.DataItem, this.SheetInfo])
        }, SaveDataField: function () {
            return {}
        }, MobilePreBack: function () {
            return true
        }, AfterMobileEditShow: function () {
        }, GetValue: function () {
            var v = null;
            if ($(this.Element).is("label,span")) {
                v = $(this.Element).html()
            } else {
                v = $(this.Element).val()
            }
            if (this.FormatRule) {
                v = v.replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "")
            }
            return v
        }, SetValue: function (obj) {
            $(this.Element).val(obj);
            if (this.IsMobile) {
                this.Mask.html(this.GetText())
            }
        }, GetText: function () {
            return $(this.Element).val()
        }, SetReadonly: function (flag) {
        }, SetVisiable: function (flag) {
            if (flag) {
                $(this.Element).show()
            } else {
                $(this.Element).hide()
            }
        }, Validate: function (effective, initValid) {
            if (!this.Editable) {
                return true
            }
            if (initValid) {
                if (this.Required && !this.GetValue()) {
                    this.AddInvalidText(this.Element, "*", false);
                    return false
                } else {
                    return true
                }
            }
            if (!effective) {
                if (this.Required) {
                    if (!this.GetValue()) {
                        this.AddInvalidText(this.Element, "*");
                        return false
                    } else {
                        this.RemoveInvalidText(this.Element)
                    }
                }
            }
            return true
        }, DoValidate: function (f, arg, message) {
            if (!f) {
                return true
            }
            if (!f.apply(this, arg)) {
                this.AddInvalidText(this.Element, message);
                return false
            } else {
                this.RemoveInvalidText(this.Element);
                return true
            }
        }, Valid: {
            RegularExpression: function (val, expression) {
                try {
                    return eval(expression).test(val)
                } catch (e) {
                    alert(MvcSheetUIGlobalString.RegularExpression_errorMessage + expression);
                    return true
                }
            }, Required: function (val) {
                if (!val) {
                    return false
                }
                return val.trim()
            }, Integer: function (val) {
                return /^(-|\+)?(\d)*$/.test(val)
            }, Number: function (val) {
                return /^[\+\-]?\d*?\.?\d*?$/.test(val)
            }, TimeSpan: function (val) {
                return /^((20|21|22|23|[0-1]\d)\:[0-5][0-9])(\:[0-5][0-9])?$/.test(val)
            }
        }, SetFocus: function () {
            $(this.Element).focus()
        }, RenderDataTrackLink: function () {
            var popupWindowId = (this.Element.id || "") + "_PopWindow";
            var html = '<a class="nav-icon fa fa-list-alt" style="padding-left:5px" data-toggle="modal" data-target=\'#' + popupWindowId + "'></a>";
            $(html).insertAfter($(this.Element));
            var url = $.MvcSheetUI.PortalRoot + "/InstanceDataTrack.aspx?";
            url += "InstanceId=" + $.MvcSheetUI.SheetInfo.InstanceId + "&ItemName=" + this.DataField + "&F=frm_" + popupWindowId;
            this.CreatePopupDiv(popupWindowId, "修改痕迹", url, "400px")
        }, RefreshDataTrackLink: function () {
            var controlId = (this.Element.id || "") + "_PopWindow";
            var frm = document.getElementById("frm_" + controlId);
            if (frm && frm.src) {
                frm.src = frm.src
            }
        }, CreatePopupDiv: function (controlId, displayText, url, height) {
            var popupDiv = "<div id='" + controlId + "' class='modal fade' tabindex='-1' role='dialog' aria-hidden='true'>";
            popupDiv += "<div class='modal-dialog'>";
            popupDiv += "<div class='modal-content'>";
            popupDiv += "<div class='modal-header'>";
            popupDiv += "<button type='button' class='close' data-dismiss='modal'>";
            popupDiv += "<span aria-hidden='true'>&times;</span></button>";
            popupDiv += "<h4 class='modal-title'>" + displayText + "</h4>";
            popupDiv += "</div><div class='modal-body'>";
            popupDiv += '<iframe id="frm_' + controlId + "\" src='" + url + "' scrolling='no' frameborder='0' width='100%' height='" + height + "'></iframe>";
            popupDiv += "</div></div></div></div>";
            popupDiv = $(popupDiv);
            $(this.Element).after(popupDiv)
        }, GetFromatValue: function (element, value) {
            if (!this.FormatRule) {
                return ""
            }
            if (value == null) {
                return ""
            }
            $.MvcSheet.Action({
                Action: this.FormatAction,
                Datas: [this.FormatRule, value ? value.toString() : ""],
                Mask: false,
                LoadControlValue: false,
                OnActionDone: function (e) {
                    if (element.is("label,span")) {
                        element.html(e)
                    } else {
                        if (element.is("input")) {
                            element.val(e)
                        }
                    }
                }
            })
        }
    }
})(jQuery);
(function ($) {
    $.fn.SheetAttachment = function () {
        return $.MvcSheetUI.Run.call(this, "SheetAttachment", arguments)
    };
    $.MvcSheetUI.Controls.SheetAttachment = function (element, ptions, sheetInfo) {
        this.SheetAttachmentHandler = _PORTALROOT_GLOBAL + "/Ajax/FileUploadHandler.ashx";
        this.FileUpload = $("<input type='file' />").attr("data-attachment", true);
        this.Files = 0;
        this.AddAttachments = {};
        this.UploadAttachmentsIds = [];
        this.RomveAttachments = [];
        this.XHRJson = {};
        this.SchemaCode = "";
        this.Multiple = true;
        $.MvcSheetUI.Controls.SheetAttachment.Base.constructor.call(this, element, ptions, sheetInfo)
    };
    $.MvcSheetUI.Controls.SheetAttachment.Inherit($.MvcSheetUI.IControl, {
        Render: function () {
            if (!this.Visiable) {
                $(this.Element).hide();
                return
            }
            this.HtmlRender();
            this.InitValue();
            if ((this.IsHtml5)) {
                this.Html5Render()
            } else {
                this.NotHtml5Render()
            }
        }, RenderMobile: function () {
            this.Render();
            this.MoveToMobileContainer(this.Element)
        }, InitValue: function () {
            if (this.V) {
                if (this.BizObjectID == undefined) {
                    this.BizObjectID = this.SheetInfo.BizObjectID
                }
                for (var i = 0; i < this.V.length; ++i) {
                    this.CreateFileElement($.trim(this.V[i].Code), this.V[i].Name, this.V[i].Size, this.V[i].Url, this.V[i].ContentType)
                }
                if (!this.IsMobile && this.AllowBatchDownload && this.V.length > 1) {
                    var BatchDownload = $('<a href="' + _PORTALROOT_GLOBAL + "/ReadAttachmentBatch.aspx?BizObjectID=" + this.BizObjectID + "&BizObjectSchemaCode=" + this.SchemaCode + "&DataField=" + this.DataField + "&DisplayName=" + this.DataField + '" class="printHidden">批量下载</a>');
                    $(this.Element).append(BatchDownload);
                    if (this.IsMobile) {
                        BatchDownload.css("margin-left", "10px").css("margin-right", "10px").addClass("button").addClass("block")
                    } else {
                        BatchDownload.width("100%").addClass("btn").addClass("btn-outline").addClass("btn-lg").css("border", "1px dashed #ddd")
                    }
                }
            }
        }, Validate: function (effective, initValid) {
            if (!this.Editable) {
                return true
            }
            if (initValid) {
                if (this.Required && this.Files < 1) {
                    this.AddInvalidText(this.Element, "*", false);
                    return false
                }
            }
            if (!effective) {
                if (this.Required) {
                    if (this.Files < 1) {
                        this.AddInvalidText(this.Element, "*");
                        return false
                    }
                    if (this.Files[0] == null && $(this.Element).find("a").length < 2) {
                        this.AddInvalidText(this.Element, "*");
                        return false
                    }
                }
            }
            if (this.IsHtml5) {
                for (var key in this.AddAttachments) {
                    if (this.AddAttachments[key].state == 0) {
                        this.AddInvalidText(this.Element, SheetLanguages.Current.Uploading);
                        return false
                    }
                }
            } else {
                this.Form.submit()
            }
            this.RemoveInvalidText(this.Element);
            return true
        }, SaveDataField: function () {
            var result = {};
            if (!this.Visiable || !this.Editable) {
                return result
            }
            result[this.DataField] = this.DataItem;
            result[this.DataField].V = this.GetValue();
            return result
        }, GetValue: function () {
            var AttachmentIds = "";
            if ((this.IsHtml5)) {
                for (var key in this.AddAttachments) {
                    if (this.AddAttachments[key].state == 1 && this.AddAttachments[key].AttachmentId) {
                        AttachmentIds += this.AddAttachments[key].AttachmentId + ";"
                    }
                }
            } else {
                for (var i = 0; i < this.UploadAttachmentsIds.length; i++) {
                    AttachmentIds += this.UploadAttachmentsIds[i] + ";"
                }
            }
            var DelAttachmentIds = "";
            for (var i = 0; i < this.RomveAttachments.length; ++i) {
                DelAttachmentIds += this.RomveAttachments[i] + ";"
            }
            var result = {AttachmentIds: AttachmentIds, DelAttachmentIds: DelAttachmentIds};
            return result
        }, GetText: function () {
            return this.Files
        }, ClearFiles: function () {
            $(this.Element).html("");
            this.Files = 0;
            this.Validate()
        }, HtmlRender: function () {
            $(this.Element).addClass("SheetAttachment");
            this.UploadList = $("<table class='table table-striped'></table>").css("margin", 0).css("min-height", "0px");
            $(this.Element).append(this.UploadList)
        }, NotHtml5Render: function () {
            if (!this.Editable) {
                return
            }
            $(this.Element).width(this.Width);
            var id = $.MvcSheetUI.NewGuid();
            var param = "DataField=" + encodeURI(this.DataField) + "&PostForm=true&BizObjectID=" + this.SheetInfo.BizObjectID + "&SchemaCode=" + encodeURI(this.SchemaCode);
            param += "&MaxSize=" + (this.MaxUploadSize * 1024);
            this.Form = $('<form id="' + id + '" method="post" enctype="multipart/form-data" action="' + this.SheetAttachmentHandler + "?" + param + '"></form>');
            $(this.Element).append(this.Form);
            this.CreateFrame();
            if (this.Multiple) {
                this.BtnAdd = $("<div>" + SheetLanguages.Current.Add + "</div>").addClass("SheetAttachmentAdd");
                $(this.Form).append(this.BtnAdd);
                $(this.BtnAdd).unbind("click.AddAttachment").bind("click.AddAttachment", this, function (e) {
                    e.data.AddAttachment.apply(e.data)
                })
            } else {
                $(this.FileUpload).attr("name", $.MvcSheetUI.NewGuid());
                $(this.Form).append(this.FileUpload)
            }
            this.BtnUpload = $("<div>" + SheetLanguages.Current.Upload + "</div>").addClass("SheetAttachmentUpload");
            $(this.BtnUpload).unbind("click.UploadAttachment").bind("click.UploadAttachment", this, function (e) {
                e.data.Form.submit();
                var ids = "";
                $(e.data.Form).find("input").each(function () {
                    if (this.value) {
                        ids += "," + this.name
                    }
                    if (e.data.UploadAttachmentsIds.indexOf(this.name) == -1) {
                        e.data.UploadAttachmentsIds.push(this.name)
                    }
                });
                var that = e.data;
                if (ids) {
                    setTimeout(function () {
                        that.CheckUpload(ids)
                    }, 500)
                }
            });
            $(this.Form).append(this.BtnUpload);
            this.AddAttachment()
        }, CheckUpload: function (ids) {
            var that = this;
            $.MvcSheet.GetSheet({
                "Command": "GetAttachmentHeader",
                "Param": JSON.stringify([this.SheetInfo.SchemaCode, this.SheetInfo.BizObjectID, ids])
            }, function (data) {
                if (data && data.length > 0) {
                    for (var i = 0; i < data.length; i++) {
                        that.CreateFileElement(data[i].AttachmentID, data[i].FileName, data[i].ContentLength, that.PortalRoot + "/ReadAttachment.aspx?AttachmentID=" + data[i].AttachmentID, data[i].ContentType);
                        ids = ids.replace("," + $.trim(data[i].AttachmentID), "");
                        $("div[id='" + $.trim(data[i].AttachmentID) + "']").remove()
                    }
                }
                if (ids) {
                    setTimeout(function () {
                        that.CheckUpload(ids)
                    }, 500)
                }
            })
        }, CreateFrame: function () {
            var FrameName = "uploadFrame_" + $.MvcSheetUI.NewGuid();
            var oframe = $("<iframe name=" + FrameName + ">");
            oframe.css("display", "none");
            $("body").prepend(oframe);
            this.Form.attr("target", FrameName);
            this.Form.attr("method", "post");
            this.Form.attr("encoding", "multipart/form-data")
        }, AddAttachment: function () {
            var contentid = $.MvcSheetUI.NewGuid();
            var newContent = $("<div>").attr("id", contentid).addClass("upload").css("clear", "both");
            var fileinput = $('<input type="file" style="width:60%;"  />').attr("name", contentid);
            var btnDel = $("<a href='#' style=\"padding-left:10px;\">" + SheetLanguages.Current.Remove + "</a>").attr("data-content", contentid);
            $(btnDel).unbind("click.DeleteAttachment").bind("click.DeleteAttachment", this, function (e) {
                e.data.Files--;
                $("#" + $(this).attr("data-content")).remove()
            });
            newContent.append(fileinput).append(btnDel);
            $(this.BtnAdd).before(newContent);
            this.Files++;
            this.Validate()
        }, Html5Render: function () {
            if (!this.Editable) {
                return
            }
            if (this.Multiple) {
                this.FileUpload.attr("multiple", "multiple")
            }
            this.SheetAttachmentHandler += "?IsMobile=" + this.IsMobile + "&SchemaCode=" + encodeURI(this.SchemaCode) + "&fileid=";
            this.ActionPanel = $("<div>" + SheetLanguages.Current.DragUpload + "</div>");
            if (this.IsMobile) {
                this.ActionPanel.css("margin-left", "10px").css("margin-right", "10px").addClass("button").addClass("block")
            } else {
                this.ActionPanel.width("100%").addClass("btn").addClass("btn-outline").addClass("btn-lg").css("border", "1px dashed #ddd")
            }
            $(this.Element).append(this.ActionPanel);
            if (this.FileExtensions) {
                this.FileUpload.attr("accept", this.FileExtensions)
            }
            $(this.Element).append(this.FileUpload);
            if (this.IsMobile) {
                this.ActionPanel.hide()
            } else {
                this.FileUpload.hide()
            }
            $(this.ActionPanel).unbind("click.SheetAttachment").bind("click.SheetAttachment", this, function (e) {
                $.extend(this, e.data);
                if ($(this.Element).data($.MvcSheetUI.DataFieldKey.toLowerCase()) != this.DataField) {
                    return
                }
                this.FileUpload.click()
            });
            this.FileUpload.unbind("change.FileUpload").bind("change.FileUpload", this, function (e) {
                e.data.AddFiles.apply(e.data, [e.data.getFiles(this.files)]);
                $(this).val("")
            });
            this.BindDrag()
        }, BindDrag: function () {
            if (this.IsMobile) {
                return
            }
            $(this.ActionPanel).on({
                dragenter: function (e) {
                    e.stopPropagation();
                    e.preventDefault()
                }, dragleave: function (e) {
                    e.stopPropagation();
                    e.preventDefault()
                }, dragover: function (e) {
                    e.stopPropagation();
                    e.preventDefault()
                }
            });
            var that = this;
            this.ActionPanel[0].addEventListener("drop", function (e) {
                e.stopPropagation();
                e.preventDefault();
                var files = that.getFiles(e.dataTransfer.files);
                that.AddFiles.apply(that, [files])
            }, false)
        }, getFiles: function (files) {
            var filesArr = [];
            for (var i = 0; i < files.length; i++) {
                filesArr.push(files[i])
            }
            return filesArr
        }, _OpenImage: function (e) {
            var thisAnchor = $(e.target);
            if (!thisAnchor.is("[data-img-url]")) {
                thisAnchor = $(thisAnchor).closest("[data-img-url]")
            }
            var panelId = $(thisAnchor).attr("img-panel-id");
            if (!panelId) {
                panelId = $.uuid();
                $(thisAnchor).attr("img-panel-id", panelId);
                var _panel = $("<div>").addClass("panel").attr("id", panelId).attr("js-scrolling", "false").attr("data-footer", "none");
                var _imgWrapper = $("<div>").addClass("img-wrapper");
                var img = document.createElement("img");
                _imgWrapper.append(img);
                _panel.append(_imgWrapper);
                _panel.appendTo("#content");
                $.ui.loadContent(panelId);
                img.onload = function () {
                    var thisImg = $(arguments[0].target);
                    var imgWidth = thisImg.width();
                    var panelWidth = $(thisImg).closest(".panel").width();
                    var zoomMin = 1;
                    if (imgWidth > panelWidth) {
                        zoomMin = panelWidth / imgWidth
                    }
                    setTimeout(function () {
                        imgScroll = new IScroll(_imgWrapper.get(0), {
                            zoom: true,
                            zoomMin: zoomMin,
                            zoomMax: 4,
                            scrollX: true,
                            scrollY: true,
                            wheelAction: "zoom"
                        });
                        imgScroll.zoom(zoomMin)
                    }, 600)
                };
                img.src = $(thisAnchor).attr("data-img-url")
            } else {
                $.ui.loadContent(panelId)
            }
        }, RenderImageAnchor: function (anchor, url) {
            anchor.unbind("click").bind("click", this._OpenImage)
        }, CreateFileElement: function (fileid, name, size, url, contentType) {
            var fileSizeStr = 0;
            if (size > 1024 * 1024) {
                fileSizeStr = (Math.round(size * 100 / (1024 * 1024)) / 100).toString() + "MB"
            } else {
                fileSizeStr = (Math.round(size * 100 / 1024) / 100).toString() + "KB"
            }
            var fileSize = $("<td data-filesize='" + fileid + "'><span data-filerate='" + fileid + "'>" + SheetLanguages.Current.Loading + "</span> (" + fileSizeStr + ")</td>").addClass("text-info");
            var actionTd = $("<td data-action='" + fileid + '\' class="printHidden"></td>');
            var actionStr = $("<a href='javascript:void(0);' class='fa fa-minus'>" + SheetLanguages.Current.Remove + "</a>");
            if (this.Editable) {
                actionStr.unbind("click.fileDeleteBtn").bind("click.fileDeleteBtn", this, function (e) {
                    if (confirm(SheetLanguages.Current.ConfirmRemove)) {
                        e.data.RemoveFile.apply(e.data, [$(this).closest("tr").attr("id")])
                    }
                })
            } else {
                actionStr.hide()
            }
            var flag = true;
            var fileName = name;
            var fileType = "";
            if (fileName.lastIndexOf(".") > 0) {
                fileName = name.substring(0, name.lastIndexOf("."));
                fileType = name.substring(name.lastIndexOf("."), name.length)
            }
            if (url == undefined) {
                if (this.FileExtensions) {
                    if (fileType != "") {
                        if (this.FileExtensions.indexOf(fileType) < 0) {
                            flag = false
                        }
                    } else {
                        flag = false
                    }
                }
                if (!flag) {
                    fileSize = $("<td data-filesize='" + fileid + "'><span data-filerate='" + fileid + "' style='color:red;'>" + SheetLanguages.Current.FileExtError + "</span> (" + fileSizeStr + ")</td>").addClass("text-info")
                } else {
                    var mbSize = Math.round(size * 100 / (1024 * 1024)) / 100;
                    if (size > 1024 * 1024 && mbSize > this.MaxUploadSize) {
                        flag = false;
                        fileSize = $("<td data-filesize='" + fileid + "'><span data-filerate='" + fileid + "'  style='color:red;'>" + SheetLanguages.Current.OverMaxLength + "</span> (" + fileSizeStr + ")</td>").addClass("text-info")
                    }
                }
            } else {
                if (!this.IsMobile) {
                    actionTd.append($("<a href='" + url + "' class='fa fa-download' target='_blank' UC=true>" + SheetLanguages.Current.Download + "</a>"));
                    actionTd.append("&nbsp;&nbsp;")
                }
                fileSize = $("<td data-filesize='" + fileid + "'>" + fileSizeStr + "</td>").addClass("text-info")
            }
            var trRow = $("<tr></tr>").attr("id", fileid);
            if (!this.IsMobile || url == undefined) {
                trRow.append("<td ><div class='LongWord'>" + name + "</div></td>")
            } else {
                if (this.IsMobile && contentType && contentType.toLowerCase().indexOf("image/") == 0) {
                    var anchor = $("<a data-img-url='" + url + "' href='javascript:void(0)' class='fa fa-download'><div class='LongWord'>" + name + "</div></a>");
                    trRow.append($("<td>").append(anchor));
                    this.RenderImageAnchor(anchor, url)
                } else {
                    trRow.append("<td ><a href='" + url + "' class='fa fa-download' target='_blank' UC=true><div class='LongWord'>" + name + "</div></a></td>")
                }
            }
            trRow.append(fileSize.css("text-align", "right"));
            trRow.append(actionTd.append(actionStr).css("text-align", "center"));
            this.UploadList.append(trRow);
            if (flag) {
                this.Files++
            }
            var divWidth = 150;
            if ($(this.Element).width() > 100) {
                divWidth = $(this.Element).width() / 2
            }
            trRow.find(".LongWord").width(divWidth + "px");
            var temID = $.MvcSheetUI.NewGuid();
            var wordWidth = $("<span>").attr("id", temID).text(name).appendTo("body").width();
            $("#" + temID).remove();
            if (divWidth < wordWidth) {
                trRow.find(".LongWord").attr("title", name).css("float", "left").after(fileType)
            }
            return flag
        }, AddFiles: function (files) {
            if (!this.Multiple) {
                this.ClearFiles()
            }
            if (files && files.length > 0) {
                var fileid = $.MvcSheetUI.NewGuid();
                if (this.CreateFileElement(fileid, files[0].name, files[0].size, null, files[0].type)) {
                    this.AddAttachments[fileid] = {
                        fileid: fileid,
                        file: files[0],
                        ContentType: files[0].type,
                        xhr: new XMLHttpRequest(),
                        state: 0
                    };
                    files.splice(0, 1);
                    this.UploadFile(fileid, files)
                }
            }
        }, UploadFile: function (fileid, files) {
            if (this.AddAttachments[fileid] == null && this.AddAttachments[fileid].state != 0) {
                return
            }
            var fd = new FormData();
            fd.append("fileToUpload", this.AddAttachments[fileid].file);
            fd.append("MaxSize", this.MaxUploadSize * 1024);
            var xhr = this.AddAttachments[fileid].xhr;
            xhr.context = this;
            xhr.files = files;
            xhr.upload.fileid = fileid;
            xhr.abort.fileid = fileid;
            xhr.upload.addEventListener("progress", this.UploadProgress, false);
            xhr.addEventListener("load", this.UploadComplete, false);
            xhr.addEventListener("error", this.UploadFailed, false);
            xhr.addEventListener("abort", this.UploadCanceled, false);
            xhr.open("POST", this.SheetAttachmentHandler + fileid);
            xhr.send(fd)
        }, UploadProgress: function (evt) {
            if (evt.lengthComputable) {
                var percentComplete = Math.round(evt.loaded * 100 / evt.total);
                if (percentComplete >= 100) {
                    percentComplete = 99
                }
                $("span[data-filerate='" + evt.currentTarget.fileid + "']").html(percentComplete + "%")
            } else {
                this.context.AddAttachments[evt.currentTarget.fileid].state = 100;
                $("span[data-filerate='" + evt.currentTarget.fileid + "']").css("color", "red").html(SheetLanguages.Current.UploadError)
            }
        }, UploadComplete: function (evt) {
            if (evt.target.status == 200) {
                var resultObj = eval("(" + evt.target.responseText + ")");
                var fileid = resultObj.FileId;
                this.context.AddAttachments[fileid].state = 1;
                this.context.AddAttachments[fileid].AttachmentId = resultObj.AttachmentId;
                $("td[data-action='" + fileid + "']").prepend("&nbsp;&nbsp;");
                if (this.context.IsMobile) {
                    if (this.context.AddAttachments[fileid].ContentType && this.context.AddAttachments[fileid].ContentType.toLowerCase().indexOf("image/") == 0) {
                        var anchor = $("<a>").attr("data-img-url", resultObj.Url).attr("href", "javascript:void(0)").addClass("fa").addClass("fa-download").html($("#" + fileid + ">td:first").html());
                        $("#" + fileid + ">td:first").empty().append(anchor);
                        this.context.RenderImageAnchor(anchor, resultObj.Url)
                    } else {
                        $("#" + fileid + ">td:first").html($("<a href='" + resultObj.Url + "' class='fa fa-download' target='_blank' UC=true>" + $("#" + fileid + ">td:first").html() + "</a>"))
                    }
                } else {
                    $("td[data-action='" + fileid + "']").prepend($("<a href='" + resultObj.Url + "' class='fa fa-download' target='_blank' UC=true>" + SheetLanguages.Current.Download + "</a>"))
                }
                $("span[data-filerate='" + fileid + "']").html("100%");
                this.context.Validate()
            } else {
                this.context.UploadFailed(evt)
            }
            this.context.AddFiles(this.files)
        }, UploadFailed: function (evt) {
            this.context.AddAttachments[evt.currentTarget.fileid].state = 100;
            $("span[data-filerate='" + evt.currentTarget.fileid + "']").html(SheetLanguages.Current.UploadError)
        }, UploadCanceled: function () {
        }, RemoveFile: function (fileID) {
            fileID = $.trim(fileID);
            $("#" + fileID).remove();
            this.Files--;
            if (this.AddAttachments[fileID]) {
                this.AddAttachments[fileID].xhr.abort();
                delete this.AddAttachments[fileID]
            } else {
                this.RomveAttachments.push(fileID)
            }
            this.Validate()
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetCheckbox = function () {
        return A.MvcSheetUI.Run.call(this, "SheetCheckbox", arguments)
    };
    A.MvcSheetUI.Controls.SheetCheckbox = function (D, B, C) {
        A.MvcSheetUI.Controls.SheetCheckbox.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetCheckbox.Inherit(A.MvcSheetUI.IControl, {
        Checked: false, Render: function () {
            if (this.Originate) {
                this.Checked = this.DefaultValue;
                this.Element.checked = this.DefaultValue
            } else {
                this.Checked = this.V;
                this.Element.checked = this.Checked
            }
            if (!this.Visiable) {
                this.Element.style.display = "none";
                return
            }
            A(this.Element).unbind("mouseenter").unbind("mouseover").unbind("mouseup").unbind("mouseout");
            A(this.Element).css("cursor", "pointer");
            var B = A("<div class='checkbox'><label>" + this.Text + "</label></div>");
            A(this.Element).before(B);
            A(this.Element).appendTo(B.children("label"));
            if (!this.Editable) {
                A(this.Element).prop("disabled", true);
                return
            }
            if (this.OnChange) {
                A(this.Element).unbind("click.SheetCheckbox").bind("click.SheetCheckbox", this, function (C) {
                    C.data.RunScript(C.data.Element, C.data.OnChange)
                })
            }
        }, GetValue: function () {
            return this.Element.checked
        }, SetValue: function (B) {
            if (typeof (B) == "string" && B.toLowerCase() == "true") {
                this.Checked = true
            } else {
                if (typeof (B) == "boolean" && B == true) {
                    this.Checked = true
                } else {
                    this.Checked = false
                }
            }
            this.Element.checked = this.Checked;
            if (this.IsMobile) {
                this.Switchery.setPosition()
            }
        }, RenderMobile: function () {
            if (this.V == undefined) {
                this.Checked = this.DefaultValue;
                this.Element.checked = this.DefaultValue
            } else {
                this.Checked = this.V;
                this.Element.checked = this.Checked
            }
            if (!this.Visiable) {
                return
            }
            var B = A(this.Element).attr("id");
            if (!B) {
                B = A.uuid();
                A(this.Element).attr("id", B)
            }
            if (!this.Editable) {
                A(this.Element).prop("disabled", true)
            }
            if (this.Editable) {
                this.Switchery = new Switchery(this.Element);
                A(this.Element).unbind("click.SheetCheckbox").bind("click.SheetCheckbox", this, function (C) {
                    C.data.RunScript(this, this.OnChange)
                })
            } else {
                A(this.Element).prop("disabled", true);
                this.Switchery = new Switchery(this.Element, {disabled: true});
                return
            }
        }, Validate: function () {
            return true
        }, SaveDataField: function () {
            var B = {};
            if (!this.Visiable || !this.Editable) {
                return B
            }
            B[this.DataField] = A.MvcSheetUI.GetSheetDataItem(this.DataField);
            if (!B[this.DataField]) {
                if (this.DataField.indexOf(".") == -1) {
                    alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField)
                }
                return {}
            }
            if (B[this.DataField].V != this.GetValue()) {
                B[this.DataField].V = this.GetValue();
                return B
            }
            return {}
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetCheckboxList = function () {
        return A.MvcSheetUI.Run.call(this, "SheetCheckboxList", arguments)
    };
    A.MvcSheetUI.Controls.SheetCheckboxList = function (D, B, C) {
        A.MvcSheetUI.Controls.SheetCheckboxList.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetCheckboxList.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            if (!this.Visiable) {
                A(this.Element).hide();
                return
            }
            this.HtmlRender();
            this.InitValue()
        }, GetValue: function () {
            var B = "";
            A(this.Element).find("input").each(function () {
                if (this.checked) {
                    B += A(this).val() + ";"
                }
            });
            if (this.IsMobile && !B) {
                B = this.DataItem.V
            }
            return B
        }, SetValue: function (D) {
            var C = D.split(";");
            if (C != undefined) {
                for (var B = 0; B < C.length; B++) {
                    A(this.Element).find("input").each(function () {
                        if (this.value == C[B]) {
                            A(this).prop("checked", true)
                        }
                    })
                }
            }
            if (this.IsMobile) {
                if (this.OnChange) {
                    this.RunScript(this, this.OnChange)
                }
                this.Mask.text(this.GetText())
            }
        }, GetText: function () {
            var B = "";
            A(this.Element).find("input").each(function () {
                if (this.checked) {
                    if (B) {
                        B += ","
                    }
                    B += A(this).next().text()
                }
            });
            if (this.OnChange) {
                this.RunScript(this, this.OnChange)
            }
            return B
        }, SetReadonly: function (B) {
            if (B) {
                A(this.Element).find("input").prop("disabled", true)
            } else {
                A(this.Element).find("input").prop("disabled", false)
            }
        }, SetColumns: function () {
            if (this.RepeatColumns && /^([1-9]\d*)$/.test(this.RepeatColumns)) {
                var D = (100 / this.RepeatColumns) + "%";
                var C = A(this.Element).find("div"), B;
                for (B = 0; B < C.length; B++) {
                    A(C[B]).css({"width": D})
                }
            }
        }, InitValue: function () {
            var D = undefined;
            var C = "";
            if (this.V == undefined) {
                if (this.SelectedValue == undefined || this.SelectedValue == "") {
                    return
                }
                D = this.SelectedValue.split(";")
            } else {
                D = this.V.split(";")
            }
            if (D != undefined) {
                A(this.Element).find("input").each(function () {
                    A(this).prop("checked", false)
                });
                for (var B = 0; B < D.length; B++) {
                    A(this.Element).find("input").each(function () {
                        if (this.value == D[B]) {
                            if (C) {
                                C += "、"
                            }
                            C += A(this).next().text();
                            A(this).prop("checked", true)
                        }
                    })
                }
            }
            if (this.IsMobile) {
                if (this.Editable) {
                    this.Mask.html(C)
                } else {
                    A(this.Element).html(C)
                }
            }
        }, HtmlRender: function () {
            var E = this;
            if (!this.Visiable) {
                A(this.Element).hide();
                return
            }
            A(this.Element).addClass("SheetCheckBoxList");
            this.SheetGropName = this.DataField + "_" + Math.floor(Math.random() * 1000);
            if (this.Editable && this.Required && !A(this.Element).val() && !this.IsMobile) {
                this.AddInvalidText(this.Element, "*", false)
            }
            var C = A(this.Element).html();
            A(this.Element).html("");
            if (this.MasterDataCategory) {
                var E = this;
                var H = JSON.stringify([this.MasterDataCategory]);
                if (A.MvcSheetUI.CacheData && A.MvcSheetUI.CacheData[H]) {
                    var F = A.MvcSheetUI.CacheData[H];
                    for (var B in F) {
                        E.AddCheckboxItem.apply(E, [F[B].Code, F[B].EnumValue, F[B].IsDefault])
                    }
                    E.InitValue.apply(E);
                    E.DoRepeatDirection.apply(E)
                } else {
                    A.MvcSheet.GetSheet({"Command": "GetMetadataByCategory", "Param": H}, function (K) {
                        if (K) {
                            if (!A.MvcSheetUI.CacheData) {
                                A.MvcSheetUI.CacheData = {}
                            }
                            A.MvcSheetUI.CacheData[H] = K;
                            for (var I = 0, J = K.length; I < J; I++) {
                                E.AddCheckboxItem.apply(E, [K[I].Code, K[I].EnumValue, K[I].IsDefault])
                            }
                        }
                        E.InitValue.apply(E);
                        E.DoRepeatDirection.apply(E)
                    }, null, this.DataField.indexOf(".") == -1)
                }
            } else {
                if (this.DefaultItems) {
                    var G = this.DefaultItems.split(";");
                    for (var D = 0; D < G.length; D++) {
                        E.AddCheckboxItem.apply(E, [G[D], G[D], false])
                    }
                    this.InitValue();
                    this.DoRepeatDirection()
                } else {
                    A(this.Element).html(C);
                    this.InitValue()
                }
            }
            A(E.Element).unbind("click").bind("click", [E], function (I) {
                E.SetInvalidText()
            });
            A(E.Element).unbind("change").bind("change", [E], function (I) {
                I.data[0].RunScript(this, I.data[0].OnChange)
            })
        }, RenderMobile: function () {
            this.HtmlRender();
            if (!this.Editable) {
                A(this.Element).addClass(this.Css.Readonly);
                if (!this.GetValue()) {
                    A(this.Element).hide()
                }
            } else {
                this.MoveToMobileContainer()
            }
        }, DoRepeatDirection: function () {
            if (this.RepeatDirection == "Horizontal") {
                A(this.Element).find("[SheetGropName='" + this.SheetGropName + "']").css("float", "left")
            }
            this.SetColumns()
        }, Validate: function (B, C) {
            if (!this.Editable) {
                return true
            }
            if (C || !B) {
                return this.SetInvalidText()
            }
            return true
        }, SetInvalidText: function () {
            var D = true;
            if (this.Editable && this.Required) {
                D = false;
                var B = A(this.Element).find("input");
                for (var C = 0; C < B.length; C++) {
                    if (A(B[C]).is(":checked")) {
                        D = true;
                        break
                    }
                }
                if (D) {
                    this.RemoveInvalidText(this.Element, "*", false)
                } else {
                    this.AddInvalidText(this.Element, "*", false)
                }
            }
            return D
        }, AddCheckboxItem: function (E, D, F) {
            if (D || E) {
                var C = A("<div SheetGropName='" + this.SheetGropName + "'></div>");
                var H = A.MvcSheetUI.NewGuid();
                var G = A("<input type='checkbox' />").attr("name", this.SheetGropName).attr("id", H).val(E);
                G.prop("checked", F);
                if (!this.Editable) {
                    G.prop("disabled", "disabled")
                }
                var B = A("<label for='" + H + "'>" + (D || E) + "</label>");
                A(this.Element).append(C);
                C.append(G);
                C.append(B)
            }
        }, SaveDataField: function () {
            var B = {};
            if (!this.Visiable || !this.Editable) {
                return B
            }
            B[this.DataField] = A.MvcSheetUI.GetSheetDataItem(this.DataField);
            if (!B[this.DataField]) {
                if (this.DataField.indexOf(".") == -1) {
                    alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField)
                }
                return {}
            }
            if (B[this.DataField].V != this.GetValue()) {
                B[this.DataField].V = this.GetValue();
                return B
            }
            return {}
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetComment = function () {
        return A.MvcSheetUI.Run.call(this, "SheetComment", arguments)
    };
    A.MvcSheetUI.Controls.SheetComment = function (D, B, C) {
        this.SignPosition = "BeforeComment";
        this.SignAlign = "Center";
        this.SignHeight = 0;
        this.SignWidth = 0;
        A.MvcSheetUI.Controls.SheetComment.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetComment.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            if (!this.Visiable) {
                this.Element.style.display = "none";
                return
            }
            A(this.Element).addClass("SheetComment");
            this.InitHistoryComment();
            if (!this.Editable) {
                if (!this.NullCommentTitleVisible && (!this.V || !this.V.Comments || this.V.Comments.length === 0)) {
                    A("span[" + A.MvcSheetUI.PreDataKey + A.MvcSheetUI.DataFieldKey.toLowerCase() + "='" + this.DataField + "']").parent().hide()
                }
                return
            }
            this.InitCommentInput();
            this.InitFrequentlyUsedCommentsAndSignature()
        }, RenderMobile: function () {
            this.Render()
        }, Validate: function (B, C) {
            if (!this.Editable) {
                return true
            }
            if (C) {
                if (this.Required && !this.GetValue()) {
                    this.AddInvalidText(this.Element, "*", false);
                    return false
                }
            }
            if (!B) {
                if (this.Required) {
                    if (!this.GetValue()) {
                        this.AddInvalidText(this.Element, "*");
                        return false
                    } else {
                        this.RemoveInvalidText(this.Element)
                    }
                }
            }
            return true
        }, GetValue: function () {
            return A(this.CommentInput).val()
        }, _changeSignaturePic: function (B, C) {
            if (C) {
                B.html("<img border='0' src='" + A.MvcSheetUI.PortalRoot + "/TempImages/" + C + ".jpg'>");
                var D = B.find("img");
                if (this.SignWidth) {
                    D.width(this.SignWidth)
                }
                if (this.SignHeight) {
                    D.height(this.SignHeight)
                }
                setTimeout(function () {
                    if (D.width() > B.width()) {
                        D.width(B.width())
                    }
                }, 100)
            } else {
                B.html("")
            }
        }, SetReadonly: function (B) {
            if (B) {
                A(this.Element).find("textarea").hide();
                A(this.Element).find("select").hide();
                A(this.Element).find(":checkbox").hide();
                A(this.Element).find("label").hide()
            } else {
                A(this.Element).find("textarea").show();
                A(this.Element).find("select").show();
                A(this.Element).find(":checkbox").show();
                A(this.Element).find("label").show()
            }
        }, SaveDataField: function () {
            var B = {};
            if (!this.Visiable || !this.Editable) {
                return B
            }
            B[this.DataField] = this.SheetInfo.BizObject.DataItems[this.DataField];
            if (!B[this.DataField]) {
                alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField);
                return {}
            }
            var E = false;
            var D = "";
            if (this.SignatureSel) {
                D = this.SignatureSel.val()
            }
            if (this.MyComment == undefined) {
                if (!this.GetValue()) {
                    return {}
                }
                this.MyComment = {
                    CommentID: A.MvcSheetUI.NewGuid(),
                    UserName: SheetLanguages.Current.MyComment,
                    DateStr: new Date().toString(),
                    Text: this.GetValue(),
                    Avatar: A.MvcSheetUI.PortalRoot + "/assets/images/pixel-admin/user.jpg",
                    SignatureId: D
                };
                E = true;
                this.AddCommentItem(this.MyComment)
            } else {
                var F = A("#" + this.MyComment.CommentID);
                F.find("div.comment-text").html(this.GetValue());
                var C = F.find("div.comment-signature");
                this._changeSignaturePic(C, D)
            }
            B[this.DataField].V = {
                CommentID: this.MyComment.CommentID,
                Text: this.GetValue(),
                IsNewComment: E,
                SetFrequent: this.IsMobile ? false : A(this.SaveFrequentCk).is(":checked"),
                SignatureId: D
            };
            return B
        }, InitHistoryComment: function () {
            if (this.V && this.V.Comments) {
                var C = false;
                for (var B = 0; B < this.V.Comments.length; B++) {
                    if (this.LastestCommentOnly && B < this.V.Comments.length - 1) {
                        continue
                    }
                    var D = this.V.Comments[B];
                    if (D.IsMyComment) {
                        this.MyComment = D;
                        this.MyComment.UserName = SheetLanguages.Current.MyComment
                    }
                    C = (this.V.Comments.length > 0 && B < this.V.Comments.length - 1);
                    if (D.Approval != undefined && D.Approval != -1) {
                        this.AddCommentItem(D, C)
                    }
                }
            }
        }, AddCommentItem: function (N, M) {
            if (this.PanelBody == undefined) {
                var H = A('<div class="widget-comments"></div>');
                if (this.DisplayBorder) {
                    H.addClass("bordered")
                }
                this.PanelBody = A("<div></div>");
                H.append(this.PanelBody);
                A(this.Element).prepend(H)
            }
            var K = A("<div class='comment'></div>").attr("id", N.CommentID);
            var B = A("<div class='comment-body'></div>");
            if (!this.DisplayHead) {
                B.css("margin-left:3px")
            }
            if (M) {
                B.addClass("comment-line")
            }
            if (this.DisplayHead) {
                var L = A("<img src='" + N.Avatar + "' class='comment-avatar'></img>");
                K.append(L)
            } else {
                B.css({"padding-left": 0});
                B.css({"margin-left": 0})
            }
            var P = N.UserName;
            if (this.OUNameVisible && N.OUName != undefined) {
                P = N.OUName + " " + P
            }
            var D = "";
            var G = new Date(N.DateStr);
            var E = new Date();
            if (G.getYear() == E.getYear() && G.getMonth() == E.getMonth() && G.getDate() == E.getDate()) {
                var J = G.getHours().toString();
                if (J.length < 2) {
                    J = "0" + J
                }
                var I = G.getMinutes().toString();
                if (I.length < 2) {
                    I = "0" + I
                }
                D = SheetLanguages.Current.Today + J + ":" + I
            } else {
                D = N.DateStr
            }
            if (N.DelegantName) {
                P += "(" + N.DelegantName + SheetLanguages.Current.Delegant + ")"
            }
            var C = A("<div class='comment-by'><a href='javascript:void(0)'>" + P + "</a> </div>");
            if (N.Activity && this.ActivityNameVisible) {
                C.append("[<a href='javascript:void(0)'>" + N.Activity + "</a>]")
            }
            var F = A("<div class='comment-text'>" + N.Text.replace(/\n/g, "<br>") + "</div>");
            if (this.IsMobile || this.DateNewLine) {
                C.append('<div style="padding-left:5px;">' + D + "</div>")
            } else {
                C.append('<span style="padding-left:5px;">' + D + "</span>")
            }
            if (this.SignPosition && this.SignPosition == "BeforeComment") {
                B.append(C);
                B.append(F)
            } else {
                B.append(F);
                C.css("text-align", "right");
                B.append(C)
            }
            K.append(B);
            var O = A("<div class='comment-signature' style='text-align:" + this.SignAlign + ";'></div>");
            B.append(O);
            if (this.DisplaySign && N.SignatureId) {
                this._changeSignaturePic(O, N.SignatureId)
            }
            this.PanelBody.append(K)
        }, InitCommentInput: function () {
            var B = A("<div></div>");
            this.CommentInput = A("<textarea/></textarea>").width(this.Width);
            if (this.IsMobile) {
                B.css("text-align", "center");
                this.CommentInput.css({
                    border: "1px solid #DFDDDD",
                    "margin-bottom": "0px"
                }).attr("PlaceHolder", "请输入审核意见")
            }
            if (this.MyComment) {
                this.CommentInput.val(this.MyComment.Text)
            } else {
                this.CommentInput.val(this.DefaultComment)
            }
            B.append(this.CommentInput);
            A(this.Element).append(B);
            A(this.CommentInput).unbind("change.CommentInput").bind("change.CommentInput", this, function (C) {
                C.data.Validate.apply(C.data)
            })
        }, InitFrequentlyUsedCommentsAndSignature: function () {
            var H = this;
            var O = A("<div></div>").width(this.Width).css({"text-align": "right"}), I, D, B, E,
                G = A("<div></div>").width(this.Width).css({"text-align": "right", "margin-top": "3px"});
            A(this.Element).append(O);
            A(this.Element).append(G);
            if (this.FrequentCommentVisible) {
                I = A("<select></select>");
                if (!this.IsMobile) {
                    I.css({width: "100%", "float": "left"})
                } else {
                    O.css("text-align", "center");
                    I.css({width: "98%", height: "initial", border: "1px solid #DFDDDD"})
                }
                I.append("<option value=''>--" + SheetLanguages.Current.SelectComment + "--</option>");
                if (this.V && this.V.FrequentlyUsedComments) {
                    for (var J = 0; J < this.V.FrequentlyUsedComments.length; J++) {
                        var C = this.V.FrequentlyUsedComments[J];
                        if (C.length > 18) {
                            C = C.substring(0, 18) + "..."
                        }
                        var K = A("<option value='" + this.V.FrequentlyUsedComments[J] + "'>" + C + "</option>");
                        I.append(K)
                    }
                }
                A(I).unbind("change.LatestCommentSel").bind("change.LatestCommentSel", this, function (Q) {
                    if (A(this).val().length > 0) {
                        Q.data.CommentInput.val(A(this).val());
                        Q.data.Validate()
                    }
                });
                O.append(I)
            }
            if (this.FrequentSettingVisible && !this.IsMobile) {
                var P = A.MvcSheetUI.NewGuid();
                D = A("<span></span>").css({"margin-left": "10px"});
                this.SaveFrequentCk = A("<input type='checkbox'/>").attr("id", P);
                var N = A("<label type='checkbox' for='" + P + "'>" + SheetLanguages.Current.FrequentlyUsedComment + "</label>");
                N.css("cursor", "pointer");
                D.append(this.SaveFrequentCk);
                D.append(N);
                O.append(D);
                if (I) {
                    I.width("80%")
                }
            }
            if (this.DisplaySign) {
                E = A("<select></select>").css({"margin-left": "20px"});
                E.append("<option value=''>--" + SheetLanguages.Current.SelectSign + "--</option>");
                var L = A.MvcSheetUI.SheetInfo.MySignatures;
                if (L) {
                    for (var J = 0, M = L.length; J < M; J++) {
                        var F = L[J];
                        var K = A("<option value='" + F.ObjectID + "'>" + (F.Name.length > 18 ? F.Name.substring(0, 18) + "..." : F.Name) + "</option>");
                        E.append(K);
                        if (F.IsDefault) {
                            E.val(F.ObjectID)
                        }
                    }
                    if (L.length == 1) {
                        E.val(L[0].ObjectID)
                    }
                    H._changeSignaturePic(G, E.val())
                }
                A(E).unbind("change.signatureSel").bind("change.signatureSel", function () {
                    H._changeSignaturePic(G, A(this).val())
                });
                O.append(E);
                if (this.MyComment) {
                    E.val(this.MyComment.SignatureId);
                    E.trigger("change")
                }
                E.width("20%");
                if (I) {
                    I.width("55%")
                }
            }
            if (this.IsMobile) {
                if (E) {
                    E.width("100%").css({"margin-left": "0", "width": "100%"})
                }
            }
            if (E) {
                this.SignatureSel = E
            }
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetCountLabel = function () {
        return A.MvcSheetUI.Run.call(this, "SheetCountLabel", arguments)
    };
    A.MvcSheetUI.Controls.SheetCountLabel = function (D, B, C) {
        A.MvcSheetUI.Controls.SheetCountLabel.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetCountLabel.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            if (arguments) {
                var B = arguments[0];
                A(this.Element).text(B);
                if (this.FormatRule) {
                    this.GetFromatValue(A(this.Element), B)
                }
            }
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetDropDownList = function () {
        return A.MvcSheetUI.Run.call(this, "SheetDropDownList", arguments)
    };
    A.MvcSheetUI.Controls.SheetDropDownList = function (D, B, C) {
        this.FilterValue = "";
        this.FilterDataFields = [];
        this.ParentFilterDataFields = [];
        A.MvcSheetUI.Controls.SheetDropDownList.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetDropDownList.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            var D = A(this.Element);
            var C = this.V;
            var I = this;
            if (!this.Visiable) {
                D.hide();
                return
            }
            if (!this.Editable) {
                D.hide()
            } else {
                if (this.Queryable && !this.IsMobile) {
                    D.select2({placeholder: this.EmptyItemText})
                }
            }
            if (this.TrackVisiable && !this.Originate && this.DataField.indexOf(".") == -1) {
                this.RenderDataTrackLink()
            }
            var M = D.children("option");
            if (this.SchemaCode.trim() != "") {
                var E = this._createFilter();
                if (this.ParentFilterDataFields.length > 0 && A.MvcSheetUI.Loading) {
                }
                console.log(this.DataField);
                var G = JSON.stringify([this.SchemaCode, this.QueryCode, E, this.DataTextField, this.DataValueField]);
                if (this.FilterValue == G) {
                    return
                }
                this.SetEmpty();
                this.SetEmptyItem();
                if (A.MvcSheetUI.CacheData && A.MvcSheetUI.CacheData[G]) {
                    var B = A.MvcSheetUI.CacheData[G];
                    for (var K in B) {
                        D.append('<option value="' + K + '">' + B[K] + "</option>")
                    }
                    this._selectItem(D, C)
                } else {
                    var L = false;
                    for (var F in E) {
                        if (E[F]) {
                            L = true;
                            break
                        }
                    }
                    if (!this.Filter || L) {
                        A.MvcSheet.GetSheet({"Command": "GetBizServiceData", "Param": G}, function (O) {
                            if (!A.MvcSheetUI.CacheData) {
                                A.MvcSheetUI.CacheData = {}
                            }
                            if (O.Successful != null && !O.Successful) {
                                console.log(O.Message)
                            } else {
                                A.MvcSheetUI.CacheData[G] = O;
                                for (var N in O) {
                                    if (!D.find("option[value='" + N + "']") || D.find("option[value='" + N + "']").length == 0) {
                                        D.append('<option value="' + N + '">' + O[N] + "</option>")
                                    }
                                }
                                I._selectItem(D, C)
                            }
                        }, null, this.DataField.indexOf(".") == -1)
                    }
                }
                this.FilterValue = G
            } else {
                if (this.MasterDataCategory.trim() != "") {
                    this.SetEmpty();
                    this.SetEmptyItem();
                    var G = JSON.stringify([this.MasterDataCategory]);
                    if (A.MvcSheetUI.CacheData && A.MvcSheetUI.CacheData[G]) {
                        var B = A.MvcSheetUI.CacheData[G];
                        for (var K in B) {
                            D.append('<option value="' + B[K].Code + '"' + (B[K].IsDefault ? ' selected="selected"' : "") + ">" + B[K].EnumValue + "</option>")
                        }
                        this._selectItem(D, C)
                    } else {
                        A.MvcSheet.GetSheet({"Command": "GetMetadataByCategory", "Param": G}, function (P) {
                            if (P) {
                                if (!A.MvcSheetUI.CacheData) {
                                    A.MvcSheetUI.CacheData = {}
                                }
                                A.MvcSheetUI.CacheData[G] = P;
                                for (var N = 0, O = P.length; N < O; N++) {
                                    D.append('<option value="' + P[N].Code + '"' + (P[N].IsDefault ? ' selected="selected"' : "") + ">" + P[N].EnumValue + "</option>")
                                }
                            }
                            I._selectItem(D, C)
                        }, null, this.DataField.indexOf(".") == -1)
                    }
                } else {
                    if (this.DefaultItems.trim() != "") {
                        this.SetEmptyItem();
                        var J = this.DefaultItems.split(";");
                        for (var H = 0; H < J.length; H++) {
                            D.append('<option value="' + J[H] + '">' + J[H] + "</option>")
                        }
                        this._selectItem(D, C)
                    } else {
                        this.SetEmptyItem();
                        if (M && M.length > 0) {
                            D.append(M);
                            D.val(D.children(":eq(0)").val());
                            this._selectItem(D, C)
                        }
                    }
                }
            }
            D.unbind("change.SheetDropDownList").bind("change.SheetDropDownList", function () {
                if (I.TextDataField) {
                    A.MvcSheetUI.SetControlValue(I.TextDataField, I.GetText(), I.RowNum)
                }
                I.Validate();
                if (I.OnChange) {
                    I.RunScript(this, I.OnChange)
                }
            })
        }, SetEmptyItem: function () {
            if (this.DisplayEmptyItem) {
                A(this.Element).append('<option value="">' + this.EmptyItemText + "</option>")
            }
        }, SetEmpty: function () {
            A(this.Element).empty();
            if (A("#s2id_" + A(this.Element).attr("id")).length > 0) {
                A("#s2id_" + A(this.Element).attr("id")).find(".select2-chosen").html("")
            }
        }, SetValue: function (B) {
            A(this.Element).val(B);
            if (this.Queryable) {
                var C = A(this.Element).find("option:selected").text();
                A("#s2id_" + this.Element.id).find(".select2-chosen").html(C)
            }
        }, GetValue: function () {
            var B = A(this.Element).val();
            if (this.IsMobile && !B) {
                B = this.DataItem.V
            }
            return B
        }, _createFilter: function () {
            var G = this;
            var D = {};
            if (this.Filter) {
                var H = this.Filter.split(",");
                var L = {};
                if (H) {
                    for (var F = 0; F < H.length; F++) {
                        if (H[F] && H[F].split(":").length == 2) {
                            var K = H[F].split(":")[0];
                            var C = H[F].split(":")[1];
                            var B = A.MvcSheetUI.GetElement(K, this.RowNum);
                            if (B) {
                                B.unbind("change." + this.DataField + this.RowNum).bind("change." + this.DataField + this.RowNum, function () {
                                    if (!A.MvcSheetUI.Loading) {
                                        G.Render()
                                    }
                                });
                                L[K] = B;
                                var J = B.SheetUIManager();
                                if (J && J instanceof A.MvcSheetUI.Controls.SheetDropDownList) {
                                    for (var I in J.FilterDataFields) {
                                        this.ParentFilterDataFields.push(J.FilterDataFields[I])
                                    }
                                    for (var I in J.ParentFilterDataFields) {
                                        this.ParentFilterDataFields.push(J.FilterDataFields[I])
                                    }
                                }
                                D[C] = A.MvcSheetUI.GetControlValue(K, this.RowNum)
                            } else {
                                if (document.getElementById(K)) {
                                    A("#" + K).unbind("change." + this.DataField + this.RowNum).bind("change." + this.DataField + this.RowNum, function () {
                                        if (!A.MvcSheetUI.Loading) {
                                            G.Render()
                                        }
                                    });
                                    D[C] = A("#" + K).val()
                                } else {
                                    D[C] = K
                                }
                            }
                            this.FilterDataFields.push(K)
                        }
                    }
                }
                for (var E in L) {
                    if (this.ParentFilterDataFields.indexOf(E) > -1) {
                        L[E].unbind("change." + this.DataField + this.RowNum)
                    }
                }
            }
            return D
        }, _selectItem: function (C, B) {
            if (!B) {
                B = this.SelectedValue
            }
            if (B != "") {
                C.val(B)
            }
            if (C.find("option:selected").length == 0 && C.find("option").length > 0) {
                C.find("option")[0].selected = true
            }
            C.trigger("change");
            if (!this.Editable) {
                var D = C.parent().find("#myselecttext");
                if (D.length > 0) {
                    D.text(this.GetText())
                } else {
                    C.after("<label id='myselecttext' style='width:100%;'>" + this.GetText() + "</label>")
                }
            }
        }, RenderMobile: function () {
            if (this.Editable) {
                this.constructor.Base.RenderMobile.apply(this)
            } else {
                this.Render()
            }
        }, GetText: function () {
            return A(this.Element).children("option:selected").text()
        }, SaveDataField: function () {
            var C = {};
            if (!this.Visiable || !this.Editable) {
                return C
            }
            if (this.DataField) {
                var D = A.MvcSheetUI.GetSheetDataItem(this.DataField, this.RowNum);
                if (D) {
                    var B = A(this.Element).val();
                    if (D.V != B) {
                        C[this.DataField] = D;
                        C[this.DataField].V = B
                    }
                } else {
                    alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField)
                }
            }
            return C
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetGridView = function () {
        A(this).find(".template>*[data-datafield]").children().each(function () {
            var B = A(this).attr("data-datafield");
            A(this).removeAttr("data-datafield").attr("data-field", B)
        });
        A(this).find("td[data-datafield]").each(function () {
            A(this).attr("data-field", A(this).attr("data-datafield"));
            A(this).removeAttr("data-datafield")
        });
        return A.MvcSheetUI.Run.call(this, "SheetGridView", arguments)
    };
    A.MvcSheetUI.Controls.SheetGridView = function (D, B, C) {
        this.pageIndex = 0;
        this.loadNum = 10;
        this.dataContainerDivHeight = 0;
        A.MvcSheetUI.Controls.SheetGridView.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetGridView.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            if (!this.Visiable) {
                if (this.VirtualPaging) {
                    A(this.Element).parent().hide()
                } else {
                    A(this.Element).hide()
                }
                return
            }
            this.HtmlRender();
            this._BindEvents();
            this.SetValue();
            this.SetVisible();
            if (this.OnRendered) {
                this.RunScript(this, this.OnRendered, arguments)
            }
        }, _BindEvents: function () {
            A(this.addbtn).unbind("click").bind("click", [this], function (B) {
                if (B.data[0]._AddRow() != undefined) {
                    B.data[0]._AddRow().apply(this, true)
                }
            });
            A(this.clearbtn).unbind("click").bind("click", [this], function (B) {
                if (B.data[0]._Clear() != undefined) {
                    B.data[0]._Clear().apply(this, arguments)
                }
            });
            A(this.exportbtn).unbind("click").bind("click", [this], function (B) {
                B.data[0]._Export.apply(B.data[0], arguments)
            });
            A(this.importbtn).find("a").unbind("click").bind("click", [this], function (B) {
                B.data[0]._Import.apply(B.data[0], arguments)
            })
        }, SetVisible: function () {
            if (this.VirtualPaging) {
                var G = A(this.Element).height();
                var D = A(this.Element).parent().parent().height();
                if (G < D) {
                    A(this.Element).parent().css("height", G + 60 + "px");
                    A(this.Element).parent().parent().css("height", G + 150 + "px")
                }
            }
            if (this.V.R) {
                if (this.V.R.length == 1 && (this.IsEmptyRow(A(this.Element).find("tr.rows:first")) || this.Originate)) {
                    if (this.DefaultRowCount > 0) {
                        for (var E = 0; E < this.DefaultRowCount - 1; E++) {
                            this._AddRow()
                        }
                    }
                }
            }
            if (!this.DisplayAdd || this.L == A.MvcSheetUI.LogicType.BizObject || !this.Editable) {
                A(this.addbtn).css("display", "none")
            }
            if (!this.DisplayExport || this.L == A.MvcSheetUI.LogicType.BizObject) {
                A(this.exportbtn).css("display", "none")
            }
            if (!this.DisplayImport || this.L == A.MvcSheetUI.LogicType.BizObject || !this.Editable) {
                A(this.importbtn).css("display", "none")
            }
            if (!this.DisplayClear || this.L == A.MvcSheetUI.LogicType.BizObject || !this.Editable) {
                A(this.clearbtn).css("display", "none")
            }
            if (!this.DisplayInsertRow || this.L == A.MvcSheetUI.LogicType.BizObject || !this.Editable) {
                A(this.Element).find("a.insert").css("display", "none")
            }
            if (!this.DisplayDelete || this.L == A.MvcSheetUI.LogicType.BizObject || !this.Editable) {
                A(this.Element).find("a.delete").css("display", "none")
            }
            if (((!this.DisplayInsertRow && !this.DisplayDelete) || !this.Editable) && this.L != A.MvcSheetUI.LogicType.BizObject) {
                if (A(this.template).length > 1) {
                    var B = A(A(this.template)[0]).find("td").length;
                    A(this.Element).find("tr").each(function (J) {
                        if (A(this).find("td").length == B) {
                            if (A(this).find("td:last").find("a.delete").length > 0) {
                                A(this).find("td:last").css("display", "none")
                            }
                        }
                    })
                } else {
                    A(this.Element).find("tr[data-row]").each(function (J) {
                        A(this).find("td:last").css("display", "none")
                    })
                }
                A(this.Element).find("tr:first").find("td:last").css("display", "none");
                A(this.Element).find("tr.footer").find("td:last").css("display", "none");
                if (this.VirtualPaging) {
                    A(A(this.Element).parent().parent().find("tr.header")).find("td:last").hide()
                }
            }
            if (!this.DisplaySequenceNo) {
                if (A(this.template).length > 1) {
                    var B = A(A(this.template)[0]).find("td").length;
                    A(this.Element).find("tr").each(function (J) {
                        if (A(this).find("td").length == B) {
                            A(this).find("td:first").css("display", "none")
                        }
                    })
                } else {
                    A(this.Element).find("tr").each(function (J) {
                        A(this).find("td:first").css("display", "none")
                    })
                }
                if (this.VirtualPaging) {
                    A(A(this.Element).parent().parent().find("tr.header")).find("td:first").hide()
                }
            }
            if (!this.DisplaySummary || this.L == A.MvcSheetUI.LogicType.BizObject) {
                A(this.Summary).css("display", "none")
            } else {
                var I = A(this.template).find("td");
                var F = false;
                for (var E = 0; E < I.length; E++) {
                    if (this.GetSummaryTd(I[E])) {
                        this._Summary(A(I[E]).children());
                        F = true
                    }
                }
                if (!F) {
                    A(this.Summary).css("display", "none")
                }
            }
            var I = A(this.Element).find("td");
            if (this.VirtualPaging) {
                I = A(this.Element).parent().parent().find("td")
            }
            for (var E = 0; E < I.length; E++) {
                var H = A(I[E]).attr("data-field");
                if (H) {
                    var C = A.MvcSheetUI.GetSheetDataItem(H, 1);
                    if (C && C.O.indexOf("V") < 0) {
                        A(I[E]).css("display", "none")
                    }
                }
            }
        }, GetSummaryTd: function (C) {
            var B = A(C).attr("data-field");
            if (B) {
                var D = A.MvcSheetUI.GetSheetDataItem(B, 1);
                if (D && (D.L == A.MvcSheetUI.LogicType.Int || D.L == A.MvcSheetUI.LogicType.Double || D.L == A.MvcSheetUI.LogicType.Long)) {
                    return true
                }
            }
            return false
        }, _Summary: function (M) {
            var N = A(M).closest("td").attr("data-field");
            var K;
            var F = A(this.Summary).find("label");
            for (var J = 0; J < F.length; J++) {
                if (A(F[J]).attr("data-datafield") == N) {
                    K = A(F[J])
                }
            }
            var C = 0;
            var H = 0;
            var B = new Array();
            var O = A(this.Element).find("tr.rows").find("td");
            for (var J = 0; J < O.length; J++) {
                if (A(O[J]).attr("data-field") == N) {
                    var E = A(O[J]).children().val() || "0";
                    var G = 0;
                    if (!isNaN(E)) {
                        G = parseFloat(E.replace(/,/g, "").replace(/$/g, "").replace(/¥/g, ""));
                        H += G
                    }
                    C++;
                    B.push(G)
                }
            }
            var D = Math.max.apply(Math, B);
            var I = Math.min.apply(Math, B);
            var L = A(K).SheetCountLabel();
            if (L && L.StatType) {
                switch (L.StatType) {
                    case "SUM":
                        L.Render(H);
                        break;
                    case "AVG":
                        L.Render((H / C).toFixed(2));
                        break;
                    case "MAX":
                        L.Render(D);
                        break;
                    case "MIN":
                        L.Render(I);
                        break;
                    default:
                        break
                }
            }
        }, _SummaryOTher: function (D) {
            var B = A(D).attr(A.MvcSheetUI.PreDataKey + A.MvcSheetUI.DataFieldKey);
            if (!B) {
                return
            }
            var E = A(D).parent();
            var C = 0;
            while (!E.is("tr")) {
                E = E.parent();
                C++;
                if (C > 10) {
                    break
                }
            }
            var F = E.find("input[data-computationrule*='{" + B + "}'],label[data-computationrule*='{" + B + "}'],span[data-computationrule*='{" + B + "}']");
            if (F.length > 0) {
                for (var C = 0; C < F.length; C++) {
                    this._Summary(F[C])
                }
            }
        }, GetText: function () {
            var B = 0;
            if (this.IsMobile) {
                B = A(this.Element).find("ul.list").length - 1
            } else {
                B = A(this.Element).find("tr.rows").length
            }
            return B + SheetLanguages.Current.Records
        }, GetValue: function () {
            var H = new Array();
            var K = {};
            if (this.IsMobile) {
                var G = this.MobileRows;
                if (G) {
                    for (var I = 0; I < G.length; I++) {
                        var J = G[I];
                        if (J) {
                            var B = J.Editors;
                            for (var F = 0; F < B.length; F++) {
                                var P = B[F];
                                if (P) {
                                    var N = P.DataField;
                                    if (N) {
                                        K[N.split(".")[1]] = P.GetValue()
                                    }
                                }
                            }
                            if (J.id) {
                                K["ObjectID"] = J.id
                            }
                            H.push(K);
                            K = {}
                        }
                    }
                }
            } else {
                var D = A(this.Element).find("tr.rows");
                var E = A(this.Element).attr("id");
                var L = A(this.Element).attr("data-datafield");
                if (this.template.length > 1) {
                    for (var I = 0; I < D.length; I = I + this.template.length) {
                        var J = D[I];
                        var C = A(J).attr("data-row");
                        var O = A("#" + E + " tr[data-row='" + C + "']");
                        for (var M = 0; M < O.length; M++) {
                            if (arguments && arguments[0]) {
                                K = this.GetRowValue(O[M], K, arguments[0])
                            } else {
                                K = this.GetRowValue(O[M], K)
                            }
                        }
                        if (this.OnEditorSaving != null) {
                            this.RunScript(this, this.OnEditorSaving, [O, K])
                        }
                        H.push(K);
                        K = {}
                    }
                } else {
                    for (var I = 0; I < D.length; I++) {
                        var J = D[I];
                        if (arguments && arguments[0]) {
                            K = this.GetRowValue(J, K, arguments[0])
                        } else {
                            K = this.GetRowValue(J, K)
                        }
                        if (this.OnEditorSaving != null) {
                            this.RunScript(this, this.OnEditorSaving, [A(J), K])
                        }
                        H.push(K);
                        K = {}
                    }
                }
            }
            return H
        }, GetRowValue: function (G, H, B) {
            if (!this.IsEmptyRow(G) || (this.V && this.V.R && this.V.R.length > 0) || this.L == A.MvcSheetUI.LogicType.BizObject) {
                var M = A(G).find("td");
                for (var D = 0; D < M.length; D++) {
                    var F = M[D];
                    var I = A(F).find("[data-datafield]");
                    var K = I.attr("data-datafield");
                    if (K != undefined) {
                        if (B) {
                            var L = A.MvcSheetUI.GetSheetDataItem(K, 1);
                            if (L && L.L == A.MvcSheetUI.LogicType.Attachment) {
                                var J = I.find("table").find("tr");
                                var C = "";
                                for (var E = 0; E < J.length; E++) {
                                    C += A(J[E]).find("td:first").find("div").html() + ";"
                                }
                                H[K.split(".")[1]] = C
                            } else {
                                H[K.split(".")[1]] = I.SheetUIManager(A(G).attr("data-row")).GetValue()
                            }
                        } else {
                            if (I.SheetUIManager(A(G).attr("data-row"))) {
                                H[K.split(".")[1]] = I.SheetUIManager(A(G).attr("data-row")).GetValue()
                            }
                        }
                    }
                }
                if (A(G).attr("id") != undefined) {
                    H["ObjectID"] = A(G).attr("id")
                }
            }
            return H
        }, IsEmptyRow: function (B) {
            var D = "";
            var C = A(B).attr("data-row");
            A(B).find("td").each(function () {
                if (A(this).children().SheetUIManager(C)) {
                    if (A(this).children().attr("class") == "SheetAttachment") {
                        var E = A(this).children().SheetUIManager(C).GetValue();
                        if (E.AttachmentIds != "" || E.DelAttachmentIds != "") {
                            D += "1"
                        }
                    } else {
                        D += A(this).children().SheetUIManager(C).GetValue()
                    }
                }
            });
            if (D == "" || D.replace("0", "") == "") {
                return true
            }
            return false
        }, SetValue: function (B) {
            if (this.VirtualPaging) {
                this._SetValueByPage(0, this.loadNum, null);
                A(this.Element.parentElement).unbind("scroll.PageShow").bind("scroll.PageShow", [this], function (C) {
                    var H = A(this).scrollLeft();
                    A(this.parentElement).find(".SheetGridViewTitle").scrollLeft(H);
                    var O = false;
                    var G = A(this).height();
                    var L = A(this).find("table[data-type='SheetGridView']").height();
                    var D = A(this).scrollTop();
                    var N = Math.ceil(L / G);
                    var K = D / Number(L);
                    var E = (N - 2) / N;
                    if (K > E) {
                        O = true;
                        var I = C.data[0].pageIndex;
                        var M = C.data[0].loadNum;
                        var F = I * M;
                        var J = (I + 1) * M;
                        C.data[0]._SetValueByPage(F, J, B)
                    }
                })
            } else {
                this._SetValueByPage(0, -1, B)
            }
        }, _SetValueByPage: function (F, G, E) {
            if (this.V.T) {
                this.DefaultRow = this.V.T
            }
            var B = E || this.V.R;
            if (!B) {
                return
            }
            if (G == -1) {
                G = B.length
            }
            if (this.Originate && this.DefaultRowCount < 1) {
                return
            }
            if (this.L == A.MvcSheetUI.LogicType.BizObjectArray) {
                if (F < B.length) {
                    for (var C = F; C < G; C++) {
                        var D = B[C];
                        if (D != undefined) {
                            var H = A(this.Element).attr("data-datafield") + ".ObjectID";
                            if (this.IsMobile) {
                                this._AddMobileRow(D.DataItems[H].V)
                            } else {
                                this._AddRow(D.DataItems[H].V)
                            }
                        }
                    }
                    this.pageIndex += 1
                }
            } else {
                if (this.L == A.MvcSheetUI.LogicType.BizObject) {
                    if (this.IsMobile) {
                        this._AddMobileRow()
                    } else {
                        this.newRow = A(this.Element).find("tr.template").removeClass("template").addClass("rows").attr("data-row", "1");
                        var H = this.V.DataItems[A(this.Element).attr("data-datafield") + ".ObjectID"].V;
                        A(this.newRow).attr("id", H);
                        A(this.newRow).find("td").each(function () {
                            var J = A(this).find("[data-field]");
                            var I = A(J).attr("data-field");
                            A(J).removeAttr("data-field").attr("data-datafield", I).attr("data-row", "1");
                            A(J).SheetUIManager(1)
                        })
                    }
                }
            }
        }, HtmlRender: function () {
            if (this.VirtualPaging) {
                this._RenderVirtualPagingContainer()
            }
            this.ButtonId = this.DataField + "_" + Math.floor(Math.random() * 1000);
            this.RowCount = 0;
            this.RowNum = 0;
            this.template = A(this.Element).find("tr.template");
            var C = this.template.find("td");
            this.Summary = A(this.Element).find("tr.footer");
            var B = A("<div></div>").css("width", "100%");
            this.addbtn = A("<div><a id='Add_" + this.ButtonId + "'>" + SheetLanguages.Current.Add + "</a></div>").css("width", "8%").css("float", "left").css("padding-top", "3px");
            this.clearbtn = A("<div><a id='Clear_" + this.ButtonId + "'>" + SheetLanguages.Current.Clear + "</a></div>").css("width", "8%").css("float", "left").css("padding-top", "3px");
            this.importbtn = A("<div><input id='importExcel_" + this.ButtonId + "' name='importExcel' type='file' style='width:60%' /><a id='Import_" + this.ButtonId + "'>" + SheetLanguages.Current.Import + "</a></div>").css("float", "left");
            this.exportbtn = A("<div><a id='Export_" + this.ButtonId + "'>" + SheetLanguages.Current.Export + "</a></div>").css("width", "8%").css("float", "left").css("padding-top", "3px");
            B.append(this.addbtn).append(this.clearbtn).append(this.exportbtn).append(this.importbtn);
            if (this.VirtualPaging) {
                A(this.Element).parent().after(B)
            } else {
                A(this.Element).after(B)
            }
        }, _RenderVirtualPagingContainer: function () {
            this.dataContainerDivHeight = A(this.Element).parent().height() - 80;
            var G = A(this.Element).width();
            var C = A("<div class='SheetGridView SheetGridViewTitle' data-datafield='" + this.DataField + "' style='overflow:hidden;width:100%;'></div>");
            var D = A("<div class='SheetGridView SheetGridViewData' data-datafield='" + this.DataField + "' data-type='SheetGridView' style='overflow:auto;width:100%;height:" + this.dataContainerDivHeight + "px;'></div>");
            A(this.Element).parent().append(C);
            A(this.Element).parent().append(D);
            D.append(A(this.Element));
            var B = A("<table class='SheetGridView'></table>").css("width", G);
            var E = A("<tbody class=''></tbody>");
            var F = A(this.Element).find("tr.header");
            E.append(F);
            B.append(E);
            C.append(B);
            D.css("overflow", "inherit")
        }, RenderMobile: function () {
            if (!this.Visiable) {
                A(this.Element).hide();
                return
            }
            var G = A(this.Element).data(A.MvcSheetUI.DataFieldKey.toLowerCase());
            var I = A(this.Element).data(A.MvcSheetUI.SheetIDKey);
            this.template = A(this.Element).find(".template");
            A(this.Element).find("table").remove();
            A(this.Element).data(A.MvcSheetUI.SheetIDKey, I);
            A(this.Element).parent().hide();
            var B = A(this.Element).closest("div.panel-body");
            var C = A(this.Element).parent().attr("data-title") || this.DataItem.N;
            var H = A("<div>").text(C).addClass("bannerTitle");
            this.Element = A("<div>").attr("data-datafield", G);
            H.appendTo(this.Element);
            this.Element.appendTo(B);
            this.RowCount = 0;
            this.RowNum = 0;
            this.MobileRow = A("<ul></ul>").addClass("list");
            var J = A(this.template).find("td");
            if (this.L == A.MvcSheetUI.LogicType.BizObjectArray) {
                for (var D = 1; D < J.length - 1; D++) {
                    this.GetChildrenTd(J[D])
                }
            } else {
                for (var D = 0; D < J.length; D++) {
                    this.GetChildrenTd(J[D])
                }
            }
            var E = A("<li><div>" + SheetLanguages.Current.Remove + "</div></li>").addClass("delete");
            A(this.MobileRow).append(E);
            var F = A("<ul style='margin-bottom:0px!important;'></ul>").addClass("list").append(A("<li>" + SheetLanguages.Current.Add + "</li>").addClass("add"));
            if (this.L == A.MvcSheetUI.LogicType.BizObject) {
                A(E).css("display", "none");
                A(F).css("display", "none")
            }
            A(F).unbind("click").bind("click", [this], function (K) {
                if (K.data[0]._AddMobileRow() != undefined) {
                    K.data[0]._AddMobileRow().apply(this, true)
                }
            });
            A(this.Element).append(F);
            this.SetValue();
            if (!this.Editable) {
                A(F).css("display", "none")
            }
            if (this.V.R) {
                if (this.V.R.length == 1 && (this.IsEmptyRow(A(this.Element).find("tr.rows:first")) || this.Originate)) {
                    if (this.DefaultRowCount > 0) {
                        for (var D = 0; D < this.DefaultRowCount - 1; D++) {
                            this._AddMobileRow()
                        }
                    }
                }
            }
        }, GetChildrenTd: function (D) {
            var E = A(D).find("[data-field]");
            var C = A("<li></li>").addClass("from-group");
            var B = A(E).attr("data-field");
            A(E).removeAttr("data-field").attr("data-datafield", B);
            A(C).attr("data-field", B);
            var F = A.MvcSheetUI.GetSheetDataItem(B, 1);
            if (F) {
                A(C).append(A("<div></div>").addClass("col-md-2").append(A("<label>" + F.N + "</label>")))
            }
            A(C).append(A("<div></div>").addClass("col-md-4").append(A(E)));
            A(this.MobileRow).append(C)
        }, _AddMobileRow: function (C) {
            if (!this.MobileRows) {
                this.MobileRows = []
            }
            var D = this;
            if (this.OnPreAdd) {
                this.RunScript(A(this.Element), this.OnPreAdd, arguments)
            }
            MobileRowCtor = function (H, K, L, G) {
                var I = this;
                this.RowControl = A(H).clone().attr("data-row", K);
                this.RowControl.find("[data-datafield]").attr("data-row", K);
                A(G).find("ul:last").before(this.RowControl);
                if (!D.Editable) {
                    A(this.RowControl).find("li.delete").css("display", "none")
                } else {
                    A(this.RowControl).find("li.delete").unbind("click").bind("click", [this], function (N) {
                        for (var P in I.Editors) {
                            var O = A(J[P].Element).data(A.MvcSheetUI.SheetIDKey);
                            if (O && A.MvcSheetUI.ControlManagers[O]) {
                                delete A.MvcSheetUI.ControlManagers[O]
                            }
                        }
                        A(this).closest("ul").remove();
                        --D.RowCount;
                        for (var M in D.MobileRows) {
                            if (D.MobileRows[M].id == I.id) {
                                D.MobileRows.splice(M, 1);
                                break
                            }
                        }
                        if (A.MvcSheetUI.MvcRuntime) {
                            A.MvcSheetUI.MvcRuntime.init()
                        }
                    })
                }
                var J = [];
                this.RowControl.find("li.from-group").each(function () {
                    var M = A(this).children(":last").children();
                    if (A(M).attr("id")) {
                        var N = A(M).attr("id");
                        N = N + "_Row" + L;
                        A(M).attr("id", N)
                    }
                    J.push(A(M).SheetUIManager(K))
                });
                this.Editors = J;
                return this
            };
            var F = new MobileRowCtor(this.MobileRow, this.RowCount + 1, ++this.RowNum, this.Element);
            if (arguments && arguments.length > 0) {
                var B = arguments[0];
                F.id = B;
                A(F).attr("id", B)
            } else {
                F.id = A.uuid()
            }
            if (this.OnAdded) {
                this.RunScript(A(this.Element), this.OnAdded, [this, this.V.R[this.RowCount]])
            }
            ++this.RowCount;
            var E = this.RowCount;
            this.MobileRows.push(F);
            if (A.MvcSheetUI.MvcRuntime) {
                A.MvcSheetUI.MvcRuntime.init()
            }
        }, SetRowReadOnly: function (B) {
            if (B < this.V.R.length) {
                for (var C in this.V.R[B].DataItems) {
                    this.V.R[B].DataItems[C].O = this.V.R[B].DataItems[C].O.replace("E", "")
                }
            }
        }, _AddRow: function (B) {
            var C = this.RowCount;
            if (this.OnPreAdd) {
                this.RunScript(A(this.Element), this.OnPreAdd, [this, C])
            }
            this.newRow = this.template.clone(true).attr("class", "rows").attr("data-row", this.RowCount + 1).removeAttr("style", "display:none");
            A(this.newRow).find("td").each(function () {
                var N = A(this).find("[data-field]");
                var O = N.attr("data-field");
                N.removeAttr("data-field").attr("data-datafield", O);
                N.attr("data-row", A(this).closest("tr").attr("data-row"))
            });
            if (this.L == A.MvcSheetUI.LogicType.BizObjectArray) {
                if (this.newRow.length > 1) {
                    A(A(this.newRow)[0]).find("td:first").html(++this.RowCount)
                } else {
                    A(this.newRow).find("td:first").html(++this.RowCount)
                }
            }
            if (arguments && arguments.length == 1) {
                var I = arguments[0];
                A(this.newRow).attr("id", I)
            }
            if (arguments.length > 1) {
                var D = A(arguments[1]).attr("data-row") - 1 + 2;
                this.newRow.attr("data-row", D);
                if (this.newRow.length > 1) {
                    A(A(this.newRow)[0]).find("td:first").html(D);
                    var L;
                    for (var J = 0; J < this.newRow.length; J++) {
                        L = A(arguments[1]).next("tr")
                    }
                    A(L).after(this.newRow)
                } else {
                    A(this.newRow).find("td:first").html(D);
                    A(arguments[1]).after(this.newRow)
                }
            } else {
                if (A(this.Element).find("tr.rows").length == 0) {
                    if (this.template.length > 1) {
                        A(A(this.template)[this.template.length - 1]).after(this.newRow)
                    } else {
                        A(this.template).after(this.newRow)
                    }
                } else {
                    A(this.Element).find("tr.rows:last").after(this.newRow)
                }
            }
            var H = ++this.RowNum;
            var K = this;
            A(this.newRow).find("td").each(function () {
                var O = A(this).children();
                if (A(O).attr("id")) {
                    var P = A(O).attr("id");
                    P = P + "_Row" + H;
                    A(O).attr("id", P)
                }
                var N = A(O).SheetUIManager(K.RowCount)
            });
            if (this.AlternatingRowStyle && H % 2 == 0) {
                A(this.newRow).attr("style", this.AlternatingRowStyle)
            }
            var M = A(this.newRow).find("td");
            for (var J = 0; J < M.length; J++) {
                var G = M[J];
                if (this.GetSummaryTd(G)) {
                    A(G).children().unbind("change.Summary").bind("change.Summary", [this], function (N) {
                        N.data[0]._Summary(this)
                    })
                }
            }
            if (A.MvcSheetUI.MvcRuntime) {
                A.MvcSheetUI.MvcRuntime.init()
            }
            var E = A(this.newRow).find("a.delete");
            A(E).unbind("click").bind("click", [this], function (N) {
                N.data[0]._Deleterow(A(this).closest("tr"))
            });
            var F = A(this.newRow).find("a.insert");
            A(F).unbind("click").bind("click", [this], function (N) {
                N.data[0]._Insertrow(A(this).closest("tr"))
            });
            if (this.OnAdded) {
                this.RunScript(A(this.newRow), this.OnAdded, [this, this.V.R[C], C])
            }
            if (this.VirtualPaging) {
                this._SetVirtualPagingContainerHeight()
            }
        }, _Deleterow: function (D, C) {
            var H = parseInt(A(D).attr("data-row"));
            if (this.OnPreRemove) {
                this.RunScript(A(D), this.OnPreRemove)
            }
            A(D).find("[data-datafield]").each(function () {
                var J = A(this).data(A.MvcSheetUI.SheetIDKey);
                if (J && A.MvcSheetUI.ControlManagers[J]) {
                    delete A.MvcSheetUI.ControlManagers[J]
                }
            });
            A(D).remove();
            var B = A(this.Element).find("tr.rows");
            if (typeof (C) == "undefined" || !C) {
                for (var F = 0; F < B.length; F++) {
                    var G = B[F];
                    if (A(G).attr("data-row") == H) {
                        A(G).remove()
                    }
                    var E = parseInt(A(G).attr("data-row"));
                    if (E > H) {
                        if (this.AlternatingRowStyle) {
                            if (E % 2 == 1) {
                                A(G).attr("style", this.AlternatingRowStyle)
                            } else {
                                A(G).attr("style", "")
                            }
                        }
                        A(G).attr("data-row", E - 1);
                        if (A(G).find("td:first").html() == E) {
                            A(G).find("td:first").html(E - 1)
                        }
                        A(G).find("td").each(function () {
                            if (A(this).attr("data-title")) {
                                A(this).attr("data-title", E - 1)
                            }
                            if (A(this).children() && A(this).find("[data-datafield]")) {
                                A(this).find("[data-datafield]").attr("data-row", E - 1)
                            }
                        })
                    }
                }
                var I = A(this.template).find("td");
                for (var F = 0; F < I.length; F++) {
                    if (this.GetSummaryTd(I[F])) {
                        this._Summary(A(I[F]).children())
                    }
                }
            }
            this.RowCount = this.RowCount - 1;
            if (this.OnRemoved) {
                this.RunScript(A(D), this.OnRemoved)
            }
            if (typeof (C) == "undefined" || !C) {
                if (A.MvcSheetUI.MvcRuntime) {
                    A.MvcSheetUI.MvcRuntime.init()
                }
            }
            if (this.VirtualPaging) {
                this._SetVirtualPagingContainerHeight()
            }
        }, _Insertrow: function (B) {
            var C = parseInt(A(B).attr("data-row"));
            var F = A(this.Element).find("tr.rows");
            for (var D = 0; D < F.length; D++) {
                var E = F[D];
                var G = parseInt(A(E).attr("data-row"));
                if (G > C) {
                    G = G - 1 + 2;
                    A(E).attr("data-row", G);
                    if (A(E).find("td:first").html() == G - 1) {
                        A(E).find("td:first").html(G)
                    }
                }
            }
            this._AddRow(true, B)
        }, _Clear: function (C) {
            var D = this;
            A(this.Element).find("tr.rows").each(function (F) {
                D._Deleterow.apply(D, [A(this), true])
            });
            this.RowCount = 0;
            var E = A(this.template).find("td");
            for (var B = 0; B < E.length; B++) {
                if (this.GetSummaryTd(E[B])) {
                    this._Summary(A(E[B]).children())
                }
            }
            if (A.MvcSheetUI.MvcRuntime) {
                A.MvcSheetUI.MvcRuntime.init()
            }
            if (this.VirtualPaging) {
                this._SetVirtualPagingContainerHeight()
            }
        }, _SetVirtualPagingContainerHeight: function () {
            var C = this.Element;
            var E = this.Element.parentElement;
            var D = A(C).height();
            var B = this.dataContainerDivHeight;
            var B = D > B ? B : D;
            A(E).css("height", B);
            A(E.parentElement).css("height", 100 + B)
        }, _Export: function (B) {
            var E = {};
            if (this.VirtualPaging) {
                var K = A(this.Element).parent().parent().find("tr.header").find("td")
            } else {
                var K = A(this.Element).find("tr.header").find("td")
            }
            for (var F = 0; F < K.length; F++) {
                var H = A(K[F]).attr("data-field");
                if (H) {
                    var C = A.MvcSheetUI.GetSheetDataItem(H, 1);
                    if (C) {
                        E[H.split(".")[1]] = C.N
                    }
                }
            }
            var G = this.GetValue(true);
            if (this.VirtualPaging) {
                var I = this.pageIndex * this.loadNum;
                var D = this.V.R;
                if (I < D.length && I != 0) {
                    var J = this.GetNotShowData(I, "Export");
                    if (J.length > 0) {
                        for (var F = 0; F < J.length; F++) {
                            G.push(J[F])
                        }
                    }
                }
            }
            A.MvcSheet.PostSheet({"Command": "Exportexcel", "Param": JSON.stringify([G, E])}, function (L) {
                if (L) {
                    window.location.href = L
                }
            }, null, true)
        }, _Import: function (C) {
            var D = A(this.importbtn).find("input").prop("files");
            var E = D[0];
            var B = this;
            A.ajaxFileUpload({
                url: A.MvcSheetUI.PortalRoot + "/Ajax/ImportHandler.ashx",
                secureuri: false,
                fileElementId: "importExcel_" + this.ButtonId,
                dataType: "json",
                success: function (G, F) {
                    if (G.length > 0) {
                        B._ImportInit.apply(B, [G])
                    }
                },
                error: function (F) {
                }
            })
        }, _ImportInit: function (H) {
            this._Clear();
            for (var C = 0; C < H.length; C++) {
                var D = H[C];
                this._AddRow();
                var G = D.split(",");
                var E = A(this.newRow).find("td");
                var B = 0;
                for (var F = 0; F < E.length; F++) {
                    if (A(E[F]).find("[data-datafield]") && A(E[F]).find("[data-datafield]").length > 0 && A(E[F]).is(":visible")) {
                        A(E[F]).find("[data-datafield]").SheetUIManager(C + 1).SetValue(G[B]);
                        this._Summary(A(E[F]).find("[data-datafield]"));
                        B++
                    }
                }
                if (this.VirtualPaging) {
                    this.pageIndex = Math.ceil(H.length / this.loadNum)
                }
            }
        }, GetDefaultRow: function (F) {
            var C = A(this.Element).find("tr.rows")[1];
            var I = A(C).find("td");
            F.push("ObjectID");
            for (var D = 0; D < I.length; D++) {
                var E = I[D];
                var G = A(E).find("[data-datafield]");
                var H = G.attr("data-datafield");
                var B = "";
                if (H != undefined) {
                    B = H.split(".")[1];
                    F.push(B)
                }
            }
            return F
        }, GetNotShowData: function (K, B) {
            var N = [];
            var E = this.V.R;
            if (K < E.length) {
                var I = A(this.Element).attr("data-datafield");
                var Q = [];
                Q = this.GetDefaultRow(Q);
                for (var G = K; G < E.length; G++) {
                    var S = {};
                    var R = E[G].DataItems;
                    for (var D in Q) {
                        var H = Q[D];
                        if (R[I + "." + H].L == 24) {
                            if (B == "save") {
                                var T = R[I + "." + H].V;
                                var M = {};
                                var C = "";
                                var L = "";
                                if (T.length > 0) {
                                    for (var F = 0; F < T.length; F++) {
                                        C = C + T[F].Code + ";"
                                    }
                                }
                                M["AttachmentIds"] = C;
                                M["DelAttachmentIds"] = L;
                                S[H] = M
                            } else {
                                S[H] = ""
                            }
                        } else {
                            if (R[I + "." + H].L == 26) {
                                var J;
                                J = R[I + "." + H].V == null ? "" : R[I + "." + H].V;
                                S[H] = J
                            } else {
                                if (R[I + "." + H].L == 27) {
                                    var J = new Array();
                                    var O = R[I + "." + H].V;
                                    if (O == "" || O == null) {
                                        S[H] = ""
                                    } else {
                                        if (O.length > 0) {
                                            for (var F = 0; F < O.length; F++) {
                                                var P = O[F].Code;
                                                J.push(P)
                                            }
                                            S[H] = J
                                        }
                                    }
                                } else {
                                    var J;
                                    J = R[I + "." + H].V == null ? "" : R[I + "." + H].V;
                                    S[H] = J
                                }
                            }
                        }
                    }
                    N.push(S)
                }
            }
            return N
        }, SaveDataField: function () {
            var D = {};
            if (!this.Visiable || !this.Editable) {
                return D
            }
            D[this.DataField] = this.SheetInfo.BizObject.DataItems[this.DataField];
            if (!D[this.DataField]) {
                alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField);
                return {}
            }
            var F = this.GetValue();
            if (this.VirtualPaging) {
                var B = this.pageIndex * this.loadNum;
                var E = this.V.R;
                if (B < E.length && B != 0) {
                    var H = this.GetNotShowData(B, "save");
                    if (H.length > 0) {
                        for (var C = 0; C < H.length; C++) {
                            F.push(H[C])
                        }
                    }
                }
            }
            if (D[this.DataField].V != F) {
                var G = D[this.DataField].V.T;
                D[this.DataField].V = F;
                D[this.DataField].V.T = G;
                return D
            }
            return {}
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetHiddenField = function () {
        return A.MvcSheetUI.Run.call(this, "SheetHiddenField", arguments)
    };
    A.MvcSheetUI.Controls.SheetHiddenField = function (D, B, C) {
        A.MvcSheetUI.Controls.SheetHiddenField.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetHiddenField.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            var D = A(this.Element);
            var C = A.MvcSheetUI.SheetInfo.HiddenFields;
            if (C) {
                for (var B in C) {
                    if (D.attr("id") == B) {
                        D.val(C[B]);
                        break
                    }
                }
            }
        }, SaveDataField: function () {
            var C = A(this.Element);
            var B = A.MvcSheetUI.SheetInfo.HiddenFields;
            if (!B || !B[C.attr("id")]) {
                A.MvcSheetUI.HiddenFields[C.attr("id")] = C.val()
            } else {
                if (B[C.attr("id")] != C.val()) {
                    A.MvcSheetUI.HiddenFields[C.attr("id")] = C.val()
                }
            }
            return {}
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetHyperLink = function () {
        return A.MvcSheetUI.Run.call(this, "SheetHyperLink", arguments)
    };
    A.MvcSheetUI.Controls.SheetHyperLink = function (D, B, C) {
        A.MvcSheetUI.Controls.SheetHyperLink.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetHyperLink.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            var D = A(this.Element);
            if (!this.Visiable) {
                D.hide();
                return
            }
            var C = this.Text;
            if (this.TextDataField) {
                C = A.MvcSheetUI.GetControlValue(this.TextDataField, this.RowNum)
            }
            D.text(C);
            D.addClass("SheetHyperLink").addClass("printHidden");
            A("<span></span>").addClass("viewHidden").text(C).insertAfter(D);
            var B = this.NavigateUrl;
            if (this.NavigateUrlDataField) {
                B = A.MvcSheetUI.GetControlValue(this.NavigateUrlDataField, this.RowNum)
            }
            if (B && this.IsMobile) {
                if (B.indexOf("?") != -1) {
                    B += "&UC=true"
                } else {
                    B += "?UC=true"
                }
                D.attr("target", "_blank")
            }
            D.attr("href", B)
        }, RenderMobile: function () {
            this.Render()
        }, Validate: function () {
            return true
        }, SaveDataField: function () {
            return {}
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetInstancePrioritySelector = function () {
        return A.MvcSheetUI.Run.call(this, "SheetInstancePrioritySelector", arguments)
    };
    A.MvcSheetUI.Controls.SheetInstancePrioritySelector = function (D, B, C) {
        A.MvcSheetUI.Controls.SheetInstancePrioritySelector.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetInstancePrioritySelector.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            var E = A(this.Element);
            var D = this;
            if (!this.Visiable) {
                E.hide();
                return
            }
            E.unbind("change.SheetInstancePrioritySelector").bind("change.SheetInstancePrioritySelector", function () {
                if (A.isFunction(D.OnChange)) {
                    D.OnChange.apply(this)
                } else {
                    (new Function(D.OnChange)).apply(this)
                }
            });
            var C = A.MvcSheetUI.SheetInfo.Priorities;
            if (C) {
                E.empty();
                for (var B in C) {
                    E.append("<option value='" + B + "'>" + C[B] + "</option>")
                }
                this.V = this.V || this.DefaultValue;
                if (this.V && this.V != "") {
                    E.val(this.V)
                } else {
                    E.val("Normal")
                }
                if (!this.Editable) {
                    E.after("<label style='width:100%;'>" + E.children("option:selected").text() + "</label>");
                    E.hide()
                }
            }
        }, RenderMobile: function () {
            if (this.Editable) {
                this.constructor.Base.RenderMobile.apply(this)
            } else {
                this.Render()
            }
        }, GetText: function () {
            return A(this.Element).children("option:selected").text()
        }, SaveDataField: function () {
            var B = {};
            if (!this.Visiable || !this.Editable) {
                return B
            }
            B[this.DataField] = this.SheetInfo.BizObject.DataItems[this.DataField];
            if (!B[this.DataField]) {
                alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField);
                return {}
            }
            if (B[this.DataField].V != A(this.Element).val()) {
                A.MvcSheetUI.Priority = A(this.Element).val();
                B[this.DataField].V = A(this.Element).val();
                return B
            }
            return {}
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetLabel = function () {
        return A.MvcSheetUI.Run.call(this, "SheetLabel", arguments)
    };
    A.MvcSheetUI.Controls.SheetLabel = function (D, B, C) {
        A.MvcSheetUI.Controls.SheetLabel.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetLabel.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            if (!this.Visiable) {
                this.Element.style.display = "none";
                return
            }
            A(this.Element).css("display", "block");
            if (this.BindType.toLowerCase() == this.BindTypeEnum.OnlyData) {
                var D = this.V;
                var B = A(this.Element);
                if (D && (D = A.trim(D))) {
                    var C = D.split("\n");
                    A(C).each(function (E) {
                        if (E > 0) {
                            B.append("<br />")
                        }
                        B.text("");
                        B.append(A("<span></span>").text(this.toString()))
                    })
                } else {
                    B.text("")
                }
            } else {
                if (!A(this.Element).text()) {
                    A(this.Element).text(this.Text || this.N || "")
                } else {
                    if (!A(this.Element).text().trim()) {
                        if (this.DataField) {
                            A(this.Element).text(this.DataField)
                        }
                    }
                }
            }
            if (this.OnClick) {
                A(this.Element).unbind("click.SheetLabel").bind("click.SheetLabel", [this], function (E) {
                    var F = E.data[0];
                    (new Function(F.OnClick)).apply(F.Element, arguments)
                })
            }
        }, GetValue: function () {
            return A(this.Element).text() || this.DataField
        }, SaveDataField: function () {
            var B = {};
            if (!this.Visiable || !this.Editable || this.BindType.toLowerCase() == this.BindTypeEnum.OnlyVisiable) {
                return B
            }
            B[this.DataField] = A.MvcSheetUI.GetSheetDataItem(this.DataField);
            if (!B[this.DataField]) {
                if (this.DataField.indexOf(".") == -1) {
                    alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField)
                }
                return {}
            }
            if (B[this.DataField].V != A(this.Element).html()) {
                B[this.DataField].V = A(this.Element).html();
                return B
            }
            return {}
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetOffice = function () {
        return A.MvcSheetUI.Run.call(this, "SheetOffice", arguments)
    };
    A.MvcSheetUI.Controls.SheetOffice = function (D, B, C) {
        this.NTKO = null;
        A.MvcSheetUI.Controls.SheetOffice.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetOffice.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            if (typeof (wordObject) == "undefined") {
                this.wordObject = {
                    ReadOnly: false,
                    Print: false,
                    Sign: false,
                    Stamp: false,
                    Template: false,
                    Mark: false,
                    Accept: false,
                    PDF: false
                }
            } else {
                this.wordObject = wordObject
            }
            var I = A("<table border='0' style='text-align: center; width: 80%'></table>");
            var E = A("<object id='TANGER_OCX' classid='clsid:" + this.ClassID + "' codebase='" + this.CABPath + "#version=" + this.ProductVersion + "' width='" + this.OfficeWidth + "' height='" + this.OfficeHeight + "'><param name='ProductCaption' value='" + this.ProductCaption + "'><param name='ProductKey' value='" + this.ProductKey + "'></object>");
            A(I).append(A("<tr></tr>").append(A("<td style='height: " + this.OfficeHeight + ";'></td>").append(E)));
            A(this.Element).append(I);
            var H = A("<tr></tr>");
            var D = A("<td><input type='button' value='" + SheetLanguages.Current.CreatePDF + "' ></td>");
            var B = A("<td><input type='button' value='" + SheetLanguages.Current.ViewPDF + "' ></td>");
            var G = A("<td><input type='button' value='" + SheetLanguages.Current.AddESP + "' ></td>");
            var C = A("<td><input type='button' value='" + SheetLanguages.Current.AddTemplate + "' ></td>");
            A(H).append(A(D)).append(A(B)).append(A(G)).append(A(C));
            if (!this.wordObject.PDF) {
                A(D).hide();
                A(B).hide()
            }
            if (!this.wordObject.Stamp) {
                A(G).hide()
            }
            if (!this.wordObject.Template) {
                A(C).hide()
            }
            A(this.Element).before(A(H));
            A(D).unbind("click").bind("click", [this], function (J) {
                J.data[0].SavePDF()
            });
            A(B).unbind("click").bind("click", [this], function (J) {
                J.data[0].ViewPDF()
            });
            A(G).unbind("click").bind("click", [this], function (J) {
                J.data[0].AddSign()
            });
            A(C).unbind("click").bind("click", [this], function (J) {
                J.data[0].AddTemplate()
            });
            var F = this;
            setTimeout(function () {
                F.InitOffice()
            }, 1000)
        }, InitOffice: function () {
            this.NTKO = document.getElementById(A(this.Element).find("object").attr("id"));
            var B = true;
            try {
                if (this.Originate) {
                    this.NTKO.openFromUrl(this.Template)
                } else {
                    try {
                        var D = _PORTALROOT_GLOBAL + "/Office/WordOpen.aspx?SchemaCode=" + A.MvcSheetUI.SheetInfo.SchemaCode + "&BizObjectID=" + A.MvcSheetUI.SheetInfo.BizObjectID + "&dataField=" + this.DataField;
                        this.NTKO.OpenFromURL(D)
                    } catch (C) {
                        this.NTKO.openFromUrl(this.Template)
                    }
                }
            } catch (C) {
                B = false;
                alert(SheetLanguages.Current.IE)
            }
            if (B) {
                this.SetReadOnly(!this.Editable);
                this.NTKO.fileprint = this.wordObject.Print;
                this.NTKO.fileprintPreview = this.wordObject.Print;
                this.NTKO.IsNoCopy = false
            }
        }, ViewPDF: function () {
            var B = _PORTALROOT_GLOBAL + "/Office/WordOpen.aspx?SchemaCode=" + A.MvcSheetUI.SheetInfo.SchemaCode + "&BizObjectID=" + A.MvcSheetUI.SheetInfo.BizObjectID + "&dataField=" + this.PDFDataField;
            window.open(B)
        }, SetReadOnly: function (B) {
            this.NTKO.SetReadOnly(B)
        }, SaveOffice: function () {
            if (!this.NTKO.ActiveDocument.Saved) {
                if (this.wordObject.ReadOnly == null || this.wordObject.ReadOnly) {
                    return
                }
                var B = this.NTKO.SaveToURL(_PORTALROOT_GLOBAL + "/Office/OfficeService.aspx", "UploadFile", "Command=SaveDocument&InstanceID=" + A.MvcSheetUI.SheetInfo.InstanceId + "&dataField=" + this.DataField + "&SchemaCode=" + A.MvcSheetUI.SheetInfo.SchemaCode + "&BizObjectID=" + A.MvcSheetUI.SheetInfo.BizObjectID, "", document.forms[0].id, false)
            }
        }, SavePDF: function () {
            var D = 1;
            var B = "fileName.pdf";
            var C, E;
            C = E = (D == "1");
            if (this.NTKO.fileOpen && this.NTKO.IsPDFCreatorInstalled()) {
                this.setSingPrint(true);
                var F = this.NTKO.PublishAsPDFToURL(_PORTALROOT_GLOBAL + "/Office/OfficeService.aspx", "SavePDF", "DataField=" + this.PDFDataField + "&Download=" + D + "&FileName=" + encodeURI(B) + "&SchemaCode=" + A.MvcSheetUI.SheetInfo.SchemaCode + "&BizObjectID=" + A.MvcSheetUI.SheetInfo.BizObjectID, "abc.pdf", 0, null, false, true, true, "123", C, E);
                this.setSingPrint(false);
                return true
            } else {
                alert(SheetLanguages.Current.PdfNotSave);
                return false
            }
        }, AddSign: function () {
            if (this.wordObject.ReadOnly == null || this.wordObject.ReadOnly) {
                this.NTKO.SetReadOnly(false);
                this.addServerSign(this.SignUrl, this.SignBookmark, this.SignTop, this.SignLeft, "", this.SignType);
                this.NTKO.SetReadOnly(true);
                this.wordObject.ReadOnly = false
            } else {
                this.addServerSign(this.SignUrl, this.SignBookmark, this.SignTop, this.SignLeft, "", this.SignType)
            }
        }, setSingPrint: function (C) {
            var B = this.NTKO.ActiveDocument.shapes;
            for (i = 1; i <= B.Count; i++) {
                if (12 == B(i).Type) {
                    if ("NTKO.SecSignControl".toUpperCase() == B(i).OLEFormat.ClassType.toUpperCase()) {
                        if (C) {
                            B(i).OLEFormat.object.SetPrintMode(2)
                        } else {
                            B(i).OLEFormat.object.SetPrintMode(0)
                        }
                    }
                }
            }
        }, addServerSign: function (H, E, F, C, D, B) {
            if (this.NTKO.fileOpen) {
                try {
                    this.NTKO.SetReadOnly(false);
                    if (this.NTKO.ActiveDocument.BookMarks != null) {
                        if (this.NTKO.ActiveDocument.BookMarks.Exists(E)) {
                            this.NTKO.ActiveDocument.BookMarks(E).Select()
                        } else {
                            C = 100;
                            F = 200
                        }
                    }
                    if (B == "Server") {
                        this.addSecSignFromURL(this.SignUrl, A.MvcSheetUI.SheetInfo.currentUser, parseInt(C), parseInt(F))
                    } else {
                        if (B == "EKEY") {
                            this.addSecSignFromEkey(A.MvcSheetUI.SheetInfo.currentUser, parseInt(C), parseInt(F))
                        } else {
                            if (B == "2") {
                                this.addLocalSign(A.MvcSheetUI.SheetInfo.currentUser, parseInt(C), parseInt(F), "")
                            }
                        }
                    }
                } catch (G) {
                    if (this.wordObject.ReadOnly == null || this.wordObject.ReadOnly) {
                        this.NTKO.SetReadOnly(true)
                    }
                    return false
                }
            }
            return true
        }, addSignFromURL: function (E, D, B, C) {
            this.NTKO.AddSignFromURL(D, E, B, C, D, 3, 100, 1)
        }, addSecSignFromURL: function (E, D, B, C) {
            this.NTKO.AddSecSignFromURL(D, E, B, C, 1, 0, false, false, true, false, "", false, true)
        }, addSecSignFromEkey: function (D, B, C) {
            this.NTKO.AddSecSignFromEkey(D, B, C, 1, 0, false, false, true, false, "", -1, false, true)
        }, addSignFromLocal: function (E, C, D, B) {
            this.NTKO.AddSignFromLocal(E, B, true, C, D, E, 1, 100, 1)
        }, AddTemplate: function () {
            if (this.OnTemplate) {
                this.RunScript(this, this.OnTemplate)
            } else {
                try {
                    var F, D;
                    var E = SheetLanguages.Current.BookmarkNotExists;
                    F = this.NTKO.ActiveDocument;
                    D = F.Application.Selection;
                    this.NTKO.AddTemplateFromURL(this.RedTemplate);
                    for (var B = 0; B < this.bookmarks.mark.length; B++) {
                        if (this.bookmarks.mark[B] == null) {
                            continue
                        }
                        if (!F.BookMarks.Exists(this.bookmarks.mark[B].Name)) {
                            continue
                        }
                        F.BookMarks(this.bookmarks.mark[B].Name).Range.Text = this.bookmarks.mark[B].Value
                    }
                    D.EndKey(6, 1);
                    D.Delete()
                } catch (C) {
                    alert("ERROR：" + C.number + ":" + C.description)
                }
            }
        }, SaveDataField: function () {
            this.SaveOffice();
            return {}
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetQuery = function () {
        return A.MvcSheetUI.Run.call(this, "SheetQuery", arguments)
    };
    A.MvcSheetUI.Controls.SheetQuery = function (D, B, C) {
        this.QueryCss = {List: "list", AfList: "orglist"};
        this.InputMapJson = {};
        this.OutputMapJson = {};
        this.FilterFlag = true;
        this.Columns = null;
        this.ControlType = {TextBox: 0, DropdownList: 1, RadioButtonList: 2, CheckBoxList: 3, RichTextBox: 4};
        A.MvcSheetUI.Controls.SheetQuery.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetQuery.Inherit(A.MvcSheetUI.IControl, {
        Validate: function () {
            return true
        }, RenderMobile: function () {
            var B = this;
            this.MappingSetting();
            this.InitQuery()
        }, AfterMobileEditShow: function () {
            if (this.Scrllable == null || this.InputMappings.length > 0) {
                this.IsBindInputVlues = false;
                this.LoadQueryData()
            }
        }, MappingSetting: function () {
            var D = this.OutputMappings.split(",");
            for (var B = 0; B < D.length; B++) {
                var C = D[B].split(":");
                this.OutputMapJson[C[0]] = C[1]
            }
            this.InputMappingSetting()
        }, InputMappingSetting: function () {
            var E = this.InputMappings.split(",");
            for (var B = 0; B < E.length; B++) {
                var C = E[B].split(":");
                var F = C[0];
                var D = A.MvcSheetUI.GetElement(F, this.RowNum);
                if (D != null) {
                    this.InputMapJson[C[1]] = D.SheetUIManager()
                }
            }
        }, InitQuery: function () {
            A(this.Element).append('<div class="scroll-wrapper"><div class="scroller"></div></div>');
            this.UlElementID = A.MvcSheetUI.NewGuid();
            this.UlElement = A("<ul>").attr("id", this.UlElementID).addClass(this.QueryCss.AfList).addClass(this.QueryCss.List).appendTo(A(this.Element).find("div.scroller"))
        }, LoadQueryData: function () {
            var B = this;
            var C = {
                Action: "GetQuerySettingAndData",
                SchemaCode: this.SchemaCode,
                QueryCode: this.QueryCode,
                InputMapping: this.GetInputMappings()
            };
            if (B.FilterPanelID) {
                C["Action"] = "GetQueryData";
                if (!B.IsBindInputVlues) {
                    B.BindFilterInputValues.apply(B)
                }
                C["Filters"] = B.GetFilters()
            }
            if (this.Scrllable) {
                this.UlElement.html("");
                this.Scrllable.UpdateLoadParams(C)
            } else {
                this.Scrllable = new ScrollableList({
                    url: A.MvcSheetUI.PortalRoot + "/Ajax/BizQueryHandler.ashx",
                    panelSelector: "#" + this.MobilePanelID,
                    ulSelector: "#" + this.UlElementID,
                    loadMoreAble: true,
                    loadParams: C,
                    OnSucceed: function (F, E, D) {
                        B.QueryData = F.QueryData;
                        B.Columns = F.Columns;
                        if (!B.QuerySetting) {
                            B.QuerySetting = F.QuerySetting;
                            B.FilterItems = B.QuerySetting.QueryItems;
                            if (!B.FilterItems) {
                                B.FilterFlag = false
                            }
                            B.BindFilter.apply(B)
                        }
                        if (!D) {
                            B.UlElement.html("")
                        }
                        B.BindData.apply(B)
                    }
                });
                this.Scrllable.LoadItems()
            }
        }, GetDisplayName: function (B) {
            if (!this.Columns) {
                return B
            }
            return this.Columns[B] || B
        }, BindFilter: function () {
            if (!this.FilterFlag) {
                return
            }
            this.FilterFlag = false;
            this.FilterBtn = A("<a  class='icon magnifier big'></a>").css("position", "absolute").css("bottom", "20px").css("right", "50px").css("z-index", "999").css("cursor", "pointer").appendTo(A(this.Element).find(".scroll-wrapper"));
            this.FilterPanelID = A.MvcSheetUI.NewGuid();
            this.FilterPanel = A("<div>").attr("id", this.FilterPanelID).hide().appendTo(this.Element);
            var L = A("<ul>").addClass("list").appendTo(this.FilterPanel);
            for (var F = 0; F < this.FilterItems.length; F++) {
                var K = this.FilterItems[F];
                if (!K.Visible) {
                    continue
                }
                if (K.FilterType == 3) {
                    continue
                }
                var E = K.DefaultValue;
                if (this.InputMapJson[K.PropertyName]) {
                }
                var B = A("<li>").appendTo(L);
                var H = A("<label for='" + this.FilterPanelID + K.PropertyName + "'>" + this.GetDisplayName(K.PropertyName) + "</label>").css("text-align", "left");
                B.append(H);
                switch (K.DisplayType) {
                    case this.ControlType.DropdownList:
                        var J = A("<select id='" + this.FilterPanelID + K.PropertyName + "' data-property='" + K.PropertyName + "'>");
                        J.append("<option value=''>" + SheetLanguages.Current.All + "</option>");
                        var C = K.SelectedValues.split(";");
                        for (var D = 0; D < C.length; D++) {
                            if (C[D] != "") {
                                J.append("<option value='" + C[D] + "'>" + C[D] + "</option>")
                            }
                        }
                        J.val(K.DefaultValue);
                        B.append(J);
                        break;
                    case this.ControlType.RadioButtonList:
                        var C = K.SelectedValues.split(";");
                        for (var D = 0; D < C.length; D++) {
                            if (C[D] != "") {
                                var I = A.MvcSheetUI.NewGuid();
                                B.append("<input id='" + I + "' type='radio' name='" + K.PropertyName + "' value='" + C[D] + "'></input>");
                                B.append("<label for='" + I + "'>" + C[D] + "</label>")
                            }
                        }
                        A("input[name='" + K.PropertyName + "'][value='" + K.DefaultValue + "']").attr("checked", "checked");
                        B.append("<br style='clear: both;'></br>");
                        break;
                    case this.ControlType.CheckBoxList:
                        var C = K.SelectedValues.split(";");
                        for (var D = 0; D < C.length; D++) {
                            if (C[D] != "") {
                                var I = A.MvcSheetUI.NewGuid();
                                B.append("<input id='" + I + "' type='checkbox' name='" + K.PropertyName + "' value='" + C[D] + "'></input>");
                                B.append("<label for='" + I + "'>" + C[D] + "</label>")
                            }
                        }
                        A("input[name='" + K.PropertyName + "'][value='" + K.DefaultValue + "']").attr("checked", "checked");
                        B.append("<br style='clear: both;'></br>");
                        break;
                    default:
                        B.append("<input type='text' id='" + this.FilterPanelID + K.PropertyName + "' data-property='" + K.PropertyName + "'></input>");
                        A("#" + K.PropertyName).val(K.DefaultValue);
                        break
                }
            }
            A.ui.addContentDiv(this.FilterPanelID);
            this.FooterID = A.MvcSheetUI.NewGuid();
            var G = A("<footer id=" + this.FooterID + " ><a class='icon magnifier big' >" + SheetLanguages.Current.OK + "</a><footer>");
            A("#afui").append(G);
            A(G).unbind("click.footerObj").bind("click.footerObj", this, function (M) {
                M.data.LoadQueryData();
                A.ui.goBack()
            });
            this.FilterPanel.attr("data-footer", this.FooterID);
            this.FilterBtn.unbind("click.FilterBtn").bind("click.FilterBtn", this, function (M) {
                A.ui.loadContent(M.data.FilterPanelID)
            })
        }, BindFilterInputValues: function () {
            this.IsBindInputVlues = true;
            for (var B = 0; B < this.FilterItems.length; B++) {
                var C = this.FilterItems[B];
                if (!C.Visible) {
                    continue
                }
                if (C.FilterType == 3) {
                    continue
                }
                if (!this.InputMapJson[C.PropertyName]) {
                    continue
                }
                switch (C.DisplayType) {
                    case this.ControlType.RadioButtonList:
                    case this.ControlType.CheckBoxList:
                        this.FilterPanel.find("input[name='" + C.PropertyName + "'][value='" + this.InputMapJson[C.PropertyName].GetValue() + "']").attr("checked", "checked");
                        break;
                    default:
                        A("#" + this.FilterPanelID + C.PropertyName).val(this.InputMapJson[C.PropertyName].GetValue());
                        break
                }
            }
        }, GetFilters: function () {
            var C = {};
            for (var B = 0; B < this.FilterItems.length; B++) {
                var D = this.FilterItems[B];
                if (!D.Visible) {
                    continue
                }
                if (D.FilterType == 3) {
                    continue
                }
                switch (D.DisplayType) {
                    case this.ControlType.RadioButtonList:
                    case this.ControlType.CheckBoxList:
                        if (this.FilterPanel.find("input[name='" + D.PropertyName + "']:checked").val()) {
                            C[D.PropertyName] = A("input[name='" + D.PropertyName + "']:checked").val()
                        }
                        break;
                    default:
                        if (A("#" + this.FilterPanelID + D.PropertyName).val()) {
                            C[D.PropertyName] = A("#" + this.FilterPanelID + D.PropertyName).val()
                        }
                        break
                }
            }
            return JSON.stringify(C)
        }, GetInputMappings: function () {
            var C = {};
            if (this.InputMapJson) {
                for (var B in this.InputMapJson) {
                    if (this.InputMapJson[B]) {
                        C[B] = this.InputMapJson[B].GetValue()
                    }
                }
            }
            return JSON.stringify(C)
        }, getPropertyNameFromData: function (C, B) {
            for (var D in C) {
                if (D.toLocaleLowerCase() == B.toLocaleLowerCase()) {
                    return D
                }
            }
        }, BindData: function () {
            for (var C = 0; C < this.QueryData.length; C++) {
                var E = this.QueryData[C];
                var H = A("<li>").data("dataindex", C).data("v", JSON.stringify(E));
                var G = A("<p>");
                var B = A("#" + this.ElementID).attr("data-datafield");
                for (var D = 0; D < this.QuerySetting.Columns.length; D++) {
                    var F = this.QuerySetting.Columns[D].PropertyName;
                    F = this.getPropertyNameFromData(E, F);
                    if (F == this.OutputMapJson[B]) {
                        H.html("");
                        H.append("<h2>" + E[F] + "</h2>")
                    } else {
                        if (D == 0) {
                            H.append("<h2>" + E[F] + "</h2>")
                        } else {
                            if (this.QuerySetting.Columns[D].Visible == 1) {
                                G.append("<span style='font-style:italic'>" + this.GetDisplayName(F) + "</span>:" + E[F] + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")
                            }
                        }
                    }
                }
                H.append(G).appendTo(this.UlElement);
                H.unbind("click.liElement").bind("click.liElement", this, function (I) {
                    I.data.ItemClick.apply(I.data, [JSON.parse(A(this).data("v"))])
                })
            }
        }, ItemClick: function (F) {
            var B = A("#" + this.ElementID).attr("data-datafield");
            var E = A("#" + this.ElementID).attr("data-row");
            for (var C in this.OutputMapJson) {
                if (C == B) {
                    A("#" + this.ElementID).val(F[this.OutputMapJson[C]]);
                    A(this.ElementMask).text(F[this.OutputMapJson[C]]);
                    try {
                        A.MvcSheetUI.ControlManagers[A("#" + this.ElementID).data("sheetid")].Validate()
                    } catch (D) {
                    }
                } else {
                    var D = A.MvcSheetUI.GetElement(C, E);
                    if (D != null && D.data(A.MvcSheetUI.SheetIDKey)) {
                        D.SheetUIManager().SetValue(F[this.OutputMapJson[C]]);
                        if (D.SheetUIManager().Validate) {
                            D.SheetUIManager().Validate()
                        }
                    }
                }
            }
            A.ui.goBack(0)
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetRadioButtonList = function () {
        return A.MvcSheetUI.Run.call(this, "SheetRadioButtonList", arguments)
    };
    A.MvcSheetUI.Controls.SheetRadioButtonList = function (D, B, C) {
        A.MvcSheetUI.Controls.SheetRadioButtonList.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetRadioButtonList.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            if (!this.Visiable) {
                this.Element.style.display = "none";
                return
            }
            this.HtmlRender();
            A(this.Element).unbind("change.SheetRadioButtonList").bind("change.SheetRadioButtonList", [this], function (B) {
                B.data[0].RemoveInvalidText(B.data[0].Element, "*", false);
                B.data[0].RunScript(this, B.data[0].OnChange)
            })
        }, GetValue: function () {
            var B = "";
            A(this.Element).find("input").each(function () {
                if (this.checked) {
                    B = A(this).val()
                }
            });
            return B
        }, SetValue: function (B) {
            A(this.Element).find("input").each(function () {
                if (this.value == B) {
                    A(this).prop("checked", "checked")
                }
            });
            if (this.IsMobile) {
                this.Mask.text(this.GetText());
                if (this.OnChange) {
                    this.RunScript(this, this.OnChange)
                }
            }
        }, GetText: function () {
            if (this.OnChange) {
                this.RunScript(this, this.OnChange)
            }
            return A(this.Element).find("input:checked").next().text()
        }, SetReadonly: function (B) {
            if (B) {
                A(this.Element).find("input").prop("disabled", true)
            } else {
                A(this.Element).find("input").prop("disabled", false)
            }
        }, SetColumns: function () {
            if (this.RepeatColumns && /^([1-9]\d*)$/.test(this.RepeatColumns)) {
                var D = (100 / this.RepeatColumns) + "%";
                var C = A(this.Element).find("div"), B;
                for (B = 0; B < C.length; B++) {
                    A(C[B]).css({"width": D})
                }
            }
        }, SaveDataField: function () {
            var B = {};
            if (!this.Visiable || !this.Editable) {
                return B
            }
            B[this.DataField] = this.SheetInfo.BizObject.DataItems[this.DataField];
            if (!B[this.DataField]) {
                alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField);
                return {}
            }
            if (B[this.DataField].V != this.GetValue()) {
                B[this.DataField].V = this.GetValue();
                return B
            }
            return {}
        }, InitValue: function () {
            if (this.V == undefined) {
                if (this.DefaultSelected) {
                    if (A(this.Element).find("input:checked").length === 0) {
                        A(this.Element).find("input").first().prop("checked", "checked")
                    }
                    if (this.SelectedValue) {
                        A(this.Element).find("input[type='radio'][value='" + this.SelectedValue + "']").prop("checked", "checked")
                    }
                }
            } else {
                A(this.Element).find("input[type='radio'][value='" + this.V + "']").prop("checked", "checked")
            }
            if (this.IsMobile) {
                var B = A(this.Element).find("input[type='radio'][value='" + this.V + "']").text();
                if (!B) {
                    B = A(this.Element).find("input[type='radio'][value='" + this.V + "']").parent().find("label").text()
                }
                if (this.Editable) {
                    this.Mask.html(B)
                } else {
                    A(this.Element).html(B)
                }
            }
        }, HtmlRender: function () {
            if (!this.Visiable) {
                A(this.Element).hide();
                return
            }
            A(this.Element).addClass("SheetRadioButtonList");
            this.SheetGropName = this.DataField + "_" + Math.floor(Math.random() * 1000);
            var C = A(this.Element).html();
            A(this.Element).html("");
            if (this.MasterDataCategory) {
                var E = this;
                var H = JSON.stringify([this.MasterDataCategory]);
                if (A.MvcSheetUI.CacheData && A.MvcSheetUI.CacheData[H]) {
                    var F = A.MvcSheetUI.CacheData[H];
                    for (var B in F) {
                        E.AddRadioItem.apply(E, [F[B].Code, F[B].EnumValue, F[B].IsDefault])
                    }
                    E.InitValue.apply(E);
                    E.DoRepeatDirection.apply(E)
                } else {
                    A.MvcSheet.GetSheet({"Command": "GetMetadataByCategory", "Param": H}, function (K) {
                        if (K) {
                            if (!A.MvcSheetUI.CacheData) {
                                A.MvcSheetUI.CacheData = {}
                            }
                            if (K.Successful != null && !K.Successful) {
                                console.log(K.Message);
                                return
                            }
                            A.MvcSheetUI.CacheData[H] = K;
                            for (var I = 0, J = K.length; I < J; I++) {
                                E.AddRadioItem.apply(E, [K[I].Code, K[I].EnumValue, K[I].IsDefault])
                            }
                        }
                        E.InitValue.apply(E);
                        E.DoRepeatDirection.apply(E)
                    }, null, this.DataField.indexOf(".") == -1)
                }
            } else {
                if (this.DefaultItems) {
                    var G = this.DefaultItems.split(";");
                    for (var D = 0; D < G.length; D++) {
                        this.AddRadioItem.apply(this, [G[D], G[D], false])
                    }
                    this.InitValue();
                    this.DoRepeatDirection()
                } else {
                    A(this.Element).html(C);
                    this.InitValue()
                }
            }
        }, RenderMobile: function () {
            this.HtmlRender();
            if (!this.Editable) {
                A(this.Element).addClass(this.Css.Readonly)
            } else {
                this.MoveToMobileContainer()
            }
        }, DoRepeatDirection: function () {
            if (this.RepeatDirection == "Horizontal") {
                A(this.Element).find("[SheetGropName='" + this.SheetGropName + "']").css("float", "left")
            }
            this.SetColumns();
            if (this.Editable && this.Required) {
                var B = A(this.Element).find("input");
                for (var C = 0; C < B.length; C++) {
                    if (A(B[C]).prop("checked")) {
                        this.RemoveInvalidText(this.Element, "*", false)
                    }
                }
            }
        }, AddRadioItem: function (F, E, G) {
            if (E || F) {
                var B = A("<div SheetGropName='" + this.SheetGropName + "'></div>");
                var H = A.MvcSheetUI.NewGuid();
                var D = A("<input type='radio' />").prop("name", this.SheetGropName).prop("id", H).val(F);
                if (this.DefaultSelected) {
                    D.prop("checked", G)
                }
                if (!this.Editable) {
                    D.prop("disabled", true)
                }
                var C = A("<label for='" + H + "'>" + (E || F) + "</label>");
                A(this.Element).append(B);
                B.append(D);
                B.append(C)
            }
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetRelationInstance = function () {
        return A.MvcSheetUI.Run.call(this, "SheetRelationInstance", arguments)
    };
    A.MvcSheetUI.Controls.SheetRelationInstance = function (D, B, C) {
        this.RelationInstances = [];
        this.ModalId = "divModal_RelationInstance";
        this.LoadUrl = null;
        this.LinkUrl = null;
        this.InstanceTable = null;
        A.MvcSheetUI.Controls.SheetRelationInstance.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetRelationInstance.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            if (!this.Visiable) {
                A(this.Element).hide();
                return
            }
            this.LoadUrl = this.PortalRoot + "/SelectInstance.aspx?InstanceId=" + this.SheetInfo.InstanceId + "&ID=" + this.Element.id;
            this.LinkUrl = this.PortalRoot + "/InstanceSheets.aspx";
            if (this.V) {
                this.GetInstancesFromValue()
            }
            this.RenderHistory();
            if (this.Editable) {
                this.RenderUpload()
            }
        }, GetInstancesFromValue: function () {
            var C = this.V.split("#,#");
            for (var B = 0; B < C.length; B++) {
                if (C[B].indexOf("#_#") == -1) {
                    continue
                }
                var D = C[B].split("#_#");
                this.RelationInstances.push({ObjectID: D[0], InstanceId: D[1], InstanceName: D[2]})
            }
        }, GetValueFromInstances: function () {
            var C = "";
            for (var B = 0; B < this.RelationInstances.length; B++) {
                if (B > 0) {
                    C += "#,#"
                }
                C += this.RelationInstances[B].ObjectID + "#_#" + this.RelationInstances[B].InstanceId + "#_#" + this.RelationInstances[B].InstanceName
            }
            return C
        }, RenderHistory: function () {
            if (this.InstanceTable == null) {
                var C = '<table class="table table-striped" style="margin: 0px; min-height: 0px;">';
                C += "<tbody>";
                C += "</tbody>";
                C += "</table>";
                this.InstanceTable = A(C);
                this.InstanceTable.appendTo(A(this.Element))
            }
            this.InstanceTable.find("row").remove();
            for (var B = 0; B < this.RelationInstances.length; B++) {
                this.AddItem(this.RelationInstances[B])
            }
        }, RenderUpload: function () {
            var C = this.Element.id || this.DataField;
            var B = '<div class="btn btn-outline btn-lg" style="width: 100%; border: 1px dashed rgb(221, 221, 221);" data-toggle="modal" data-target="#' + this.ModalId + '">';
            B += "点击绑定流程";
            B += "</div>";
            if (A("#" + this.ModalId).length == 0) {
                B += '<div id="' + this.ModalId + '" class="modal fade" tabindex="-1" role="dialog" style="display: none;" aria-hidden="true">';
                B += '<div class="modal-dialog" style="width:600px;height:452px;">';
                B += '<div class="modal-content" style="height:100%;">';
                B += '<div class="modal-header">';
                B += '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>';
                B += '<h4 class="modal-title">请选择关联流程</h4>';
                B += "</div>";
                B += '<div class="modal-body">';
                B += '<iframe id="frm_RelationInstance" name="frm_RelationInstance" scrolling="no" frameborder="0" style="width: 100%; height: 452px;" src="' + this.LoadUrl + '"></iframe>';
                B += "</div>";
                B += "</div>";
                B += "</div>";
                B += "</div>"
            }
            A(B).appendTo(A(this.Element))
        }, AddItem: function (B) {
            var E = this;
            var D = this.LinkUrl + "?RelationID=" + encodeURI(B.InstanceId);
            var C = '<tr id="' + B.ObjectID + '">';
            C += "<td>";
            C += '<a href="' + D + '" target="_blank"><i class="fa fa-angle-right" style="padding-right:5px;"></i>' + B.InstanceName + "</a>";
            C += "</td>";
            if (this.Editable) {
                C += '<td class="printHidden" style="text-align: center;width:60px;">';
                C += '<a href="javascript:void(0);" data-action="' + B.ObjectID + '" class="fa fa-minus">删除</a>';
                C += "</td>"
            }
            C += "</tr>";
            A(C).appendTo(this.InstanceTable).find(".fa-minus").click(function () {
                var F = A(this).data("action");
                E.RemoveItem(F)
            })
        }, AddNewItem: function (B, E, D) {
            var C = {ObjectID: B, InstanceId: E, InstanceName: D};
            this.RelationInstances.push(C);
            this.AddItem(C)
        }, RemoveItem: function (C) {
            for (var B = 0; B < this.RelationInstances.length; B++) {
                if (this.RelationInstances[B].ObjectID == C) {
                    this.RelationInstances.splice(B, 1);
                    this.InstanceTable.find("#" + C).remove();
                    break
                }
            }
            if (window.frames["frm_RelationInstance"] && window.frames["frm_RelationInstance"].removeItemFromParent) {
                window.frames["frm_RelationInstance"].removeItemFromParent(C)
            }
        }, RenderMobile: function () {
            this.Render();
            this.MoveToMobileContainer(this.Element)
        }, Validate: function (B, C) {
            if (!this.Editable) {
                return true
            }
            if (C) {
                if (this.Required && this.RelationInstances < 1) {
                    this.AddInvalidText(this.Element, "*", false);
                    return false
                }
            }
            if (!B) {
                if (this.Required) {
                    if (this.RelationInstances < 1) {
                        this.AddInvalidText(this.Element, "*");
                        return false
                    }
                }
            }
            this.RemoveInvalidText(this.Element);
            return true
        }, GetValue: function () {
            return this.RelationInstances
        }, SetValue: function (B) {
            A.extend(this.RelationInstances, B);
            this.RenderHistory()
        }, SaveDataField: function () {
            var B = {};
            if (!this.Visiable || !this.Editable) {
                return B
            }
            B[this.DataField] = this.DataItem;
            B[this.DataField].V = this.GetValueFromInstances();
            return B
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetRichTextBox = function () {
        return A.MvcSheetUI.Run.call(this, "SheetRichTextBox", arguments)
    };
    A.MvcSheetUI.Controls.SheetRichTextBox = function (D, B, C) {
        this.EditorObject = null;
        this.EditorIndex = 0;
        A.MvcSheetUI.Controls.SheetRichTextBox.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetRichTextBox.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            if (!this.Visiable) {
                A(this.Element).hide();
                return
            }
            if (this.TrackVisiable && !this.Originate && this.DataField.indexOf(".") == -1) {
                this.RenderDataTrackLink()
            }
            if (!this.Element.id) {
                alert("控件:" + this.DataField + "未设置ID");
                return
            }
            if (this.IsMobile) {
                this.PlaceHolder = this.PlaceHolder || this.N
            }
            A(this.Element).attr("PlaceHolder", this.PlaceHolder);
            var B;
            if (A.MvcSheetUI.SheetInfo.SheetMode == A.MvcSheetUI.SheetMode.Originate && !this.V) {
                B = this.DefaultValue || ""
            } else {
                B = this.V || ""
            }
            this.SetValue(B);
            if (this.RichTextBox && this.Editable && !this.IsMobile) {
                this.InitKindEditor()
            }
            if (!this.Editable || this.IsMobile) {
                this.SetReadonly(true);
                return
            }
            if (this.ToolTip) {
                A(this.Element).attr("title", this.ToolTip)
            }
            A(this.Element).unbind("change.SheetRichTextBox").bind("change.SheetRichTextBox", [this], function (C) {
                C.data[0].Validate()
            })
        }, InitKindEditor: function () {
            this.EditorIndex = KindEditor.instances.length;
            var C = this.EditorIndex;
            var B = this.SheetInfo;
            KindEditor.SchemaCode = B.SchemaCode;
            KindEditor.UserID = B.UserID;
            KindEditor.BizObjectID = B.BizObjectID;
            this.EditorObject = KindEditor.create(this.Element, {
                cssPath: _PORTALROOT_GLOBAL + "/WFRes/editor/plugins/code/prettify.css",
                uploadJson: _PORTALROOT_GLOBAL + "/WFRes/editor/asp.net/upload_json.ashx",
                fileManagerJson: _PORTALROOT_GLOBAL + "/WFRes/editor/asp.net/file_manager_json.ashx",
                allowFileManager: true,
                items: ["source", "|", "undo", "redo", "|", "code", "plainpaste", "wordpaste", "|", "justifyleft", "justifycenter", "justifyright", "justifyfull", "insertorderedlist", "insertunorderedlist", "indent", "outdent", "subscript", "superscript", "clearhtml", "selectall", "|", "fullscreen", "/", "formatblock", "fontname", "fontsize", "|", "forecolor", "hilitecolor", "bold", "italic", "underline", "strikethrough", "lineheight", "removeformat", "|", "image", "table", "hr", "emoticons", "anchor", "link", "unlink", "|", "about"],
                afterCreate: function () {
                    var D = this;
                    A(D.edit.doc).on("paste", function (F) {
                        if (typeof (Worker) === "undefined") {
                            return
                        }
                        var I = (F.clipboardData || F.originalEvent.clipboardData).items, H = null, E, G;
                        for (E = 0, G = I.length; E < G; E++) {
                            if (I[E].type.indexOf("image") === 0) {
                                H = I[E].getAsFile();
                                break
                            }
                        }
                        if (H) {
                            var J = new FormData();
                            J.append("imgFile", H, "screenshot.png");
                            J.append("BizObjectID", B.BizObjectID);
                            J.append("UserID", B.UserID);
                            J.append("SchemaCode", B.SchemaCode);
                            J.append("EditorIndex", C);
                            A.ajax({
                                url: _PORTALROOT_GLOBAL + "/WFRes/editor/asp.net/upload_json.ashx",
                                type: "POST",
                                data: J,
                                cache: false,
                                processData: false,
                                contentType: false,
                                dataType: "json",
                                success: function (K) {
                                    if (K.error === 0) {
                                        KindEditor.instances[K.editorIndex].insertHtml('<img src="' + K.url + '" alt="" /> ')
                                    }
                                }
                            })
                        }
                    })
                }
            })
        }, SetReadonly: function (D) {
            if (D) {
                A(this.Element).hide();
                var C = A('<div class="SheetRichTextBox"></div>');
                var B = this.Element.value;
                C.html('<div style="overflow-x:auto;display:block;" id="divRich_' + this.Element.id + '">' + B + "</div>").insertAfter(A(this.Element));
                if (this.IsMobile) {
                    var E = {ox: 0, oy: 0, cx: 0, cy: 0};
                    document.getElementById("divRich_" + this.Element.id).addEventListener("touchstart", function () {
                        E.ox = event.targetTouches[0].pageX;
                        E.oy = event.targetTouches[0].pageY;
                        console.log("ox->" + E.ox + ",oy->" + E.oy)
                    });
                    document.getElementById("divRich_" + this.Element.id).addEventListener("touchmove", function () {
                        E.cx = event.targetTouches[0].pageX;
                        E.cy = event.targetTouches[0].pageY;
                        if (Math.abs(E.cy - E.oy) < Math.abs(E.cx - E.ox)) {
                            event.stopPropagation()
                        }
                    })
                }
                C.find("p").each(function () {
                    var F = A(this).css("text-indent");
                    if (F) {
                        F = parseInt(F.replace("px", ""));
                        if (F < 0) {
                            A(this).css("text-indent", 0)
                        }
                    }
                })
            } else {
                A(this.Element).show();
                if (A(this.Element).next().hasClass("Readonly")) {
                    A(this.Element).next().remove()
                }
            }
        }, Validate: function (B, C) {
            if (!this.Editable) {
                return true
            }
            if (C) {
                if (this.Required && !this.GetValue()) {
                    this.AddInvalidText(this.Element, "*", false);
                    return false
                }
            }
            if (!B) {
                var D = this.GetValue();
                if (this.Required && !this.DoValidate(this.Valid.Required, [D], "*")) {
                    return false
                }
                if (this.RegularExpression) {
                    if (!this.DoValidate(this.Valid.RegularExpression, [D, this.RegularExpression], this.RegularInvalidText)) {
                        return false
                    }
                }
            }
            return true
        }, GetValue: function () {
            var B;
            if (this.EditorObject != null && this.EditorObject != "" && typeof (this.EditorObject) != "undefined" && this.RichTextBox) {
                B = this.EditorObject.html()
            } else {
                B = A(this.Element).val()
            }
            if (this.AutoTrim) {
                B = B.trim()
            }
            return B
        }, SetValue: function (B) {
            if (this.RichTextBox && this.EditorObject) {
                this.EditorObject.html(B)
            } else {
                if (!this.RichTextBox && !this.Editable) {
                    B = B.replace(/\n/g, "<br>")
                }
                A(this.Element).val(B)
            }
        }, SetFocus: function () {
            if (this.RichTextBox) {
                this.EditorObject.focus()
            } else {
                return this.Element.focus()
            }
        }, SaveDataField: function () {
            var B = {};
            if (!this.Editable) {
                return B
            }
            B[this.DataField] = this.SheetInfo.BizObject.DataItems[this.DataField];
            if (!B[this.DataField]) {
                if (this.DataField.indexOf(".") == -1) {
                    alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField)
                }
                return {}
            }
            var C = this.GetValue();
            if (B[this.DataField].V != C) {
                B[this.DataField].V = C;
                return B
            }
            return {}
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetTextBox = function () {
        return A.MvcSheetUI.Run.call(this, "SheetTextBox", arguments)
    };
    A.MvcSheetUI.Controls.SheetTextBox = function (D, B, C) {
        this.TextRightAlign = false;
        this.NumberRightAlign = false;
        A.MvcSheetUI.Controls.SheetTextBox.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetTextBox.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            if (!this.Visiable) {
                this.Element.style.display = "none";
                return
            }
            if (this.TrackVisiable && !this.Originate && this.DataField.indexOf(".") == -1) {
                this.RenderDataTrackLink()
            }
            if (this.IsMobile) {
                this.PlaceHolder = this.PlaceHolder || this.N;
                this.Element.addEventListener("touchstart", function () {
                    event.stopPropagation()
                })
            }
            A(this.Element).attr("PlaceHolder", this.PlaceHolder);
            if (A.MvcSheetUI.SheetInfo.SheetMode == A.MvcSheetUI.SheetMode.Originate && !this.V) {
                if (this.DefaultValue) {
                    if (this.DefaultValue.indexOf("{") > -1 && this.DefaultValue.indexOf("}") > -1) {
                        var B = this.DefaultValue.replace("{", "").replace("}", "");
                        if (B) {
                            var C = A.MvcSheetUI.GetSheetDataItem(B, 0);
                            if (C) {
                                A(this.Element).val(C.V)
                            }
                        }
                    } else {
                        A(this.Element).val(this.DefaultValue)
                    }
                } else {
                    A(this.Element).val("")
                }
                if (!this.DefaultValue && this.V !== "") {
                    this.SetValue(this.V)
                }
            } else {
                this.SetValue(this.V)
            }
            if (!this.Editable) {
                this.SetReadonly(true);
                return
            }
            if (this.TextRightAlign) {
                A(this.Element).addClass("txtAlignRight")
            } else {
                if (this.NumberRightAlign && this.IsNubmer()) {
                    A(this.Element).addClass("txtAlignRight")
                }
            }
            if (this.ToolTip) {
                A(this.Element).attr("title", this.ToolTip)
            }
            A(this.Element).unbind("change.SheetTextBox").bind("change.SheetTextBox", [this], function (D) {
                D.data[0]._OnChange()
            });
            A(this.Element).unbind("focus.SheetTextBox").bind("focus.SheetTextBox", [this], function (D) {
                if (D.data[0].FormatRule) {
                    this.value = this.value.replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "")
                }
                if (D.data[0].OnFocus) {
                    D.data[0].RunScript(this, D.data[0].OnFocus)
                }
            });
            if (this.OnKeyUp) {
                A(this.Element).unbind("keyup.SheetTextBox").bind("keyup.SheetTextBox", [this], function (D) {
                    D.data[0].RunScript(this, D.data[0].OnKeyUp)
                })
            }
            if (this.OnKeyDown) {
                A(this.Element).unbind("keydown.SheetTextBox").bind("keydown.SheetTextBox", [this], function (D) {
                    D.data[0].RunScript(this, D.data[0].OnKeyDown)
                })
            }
            A(this.Element).unbind("blur.SheetTextBox").bind("blur.SheetTextBox", [this], function (D) {
                if (D.data[0].FormatRule) {
                    D.data[0].GetFromatValue(A(D.data[0].Element), D.data[0].GetValue())
                }
            });
            if (this.IsMobile) {
                this._mobilePopup()
            } else {
                this._createPopup()
            }
        }, IsNubmer: function () {
            return (this.LogicType == 7 || this.LogicType == 9 || this.LogicType == 35)
        }, SetValue: function (B) {
            A(this.Element).val(B);
            A(this.Element).change();
            if (this.FormatRule) {
                this.GetFromatValue(A(this.Element), B)
            }
            if (this.IsMobile) {
                this.Mask.html(this.GetText())
            }
        }, _mobilePopup: function () {
            if (this.PopupWindow == "None") {
                return
            }
            this.ViewInNewContainer = false;
            this.ID = A(this.Element).attr("Id");
            A(this.Element).hide();
            this.PopupElement = A("<div></div>").insertAfter(this.Element);
            var B = function (E) {
                this.PopupElement.SheetQuery({
                    SchemaCode: this.SchemaCode,
                    QueryCode: this.QueryCode,
                    InputMappings: this.InputMappings,
                    OutputMappings: this.OutputMappings,
                    O: this.O,
                    ElementMask: this.Mask,
                    ElementID: this.ID,
                    RowNum: this.RowNum,
                    MobilePanelID: E
                })
            };
            var C = this.MoveToMobileContainer(this.PopupElement);
            A("#" + C).css("overflow", "hidden").attr("js-scrolling", "false");
            A("#" + C).find("div.bannerTitle").remove();
            var D = A("#" + C).attr("data-title");
            B.apply(this, [C]);
            A("#" + C).attr("data-title", D)
        }, AfterMobileEditShow: function () {
            if (this.PopupElement) {
                this.PopupElement.SheetQuery().AfterMobileEditShow()
            }
        }, _createPopup: function () {
            var F = this;
            if (this.PopupWindow == "PopupWindow") {
                var B = this.DisplayText == "" ? "&nbsp;" : this.DisplayText;
                var I = "popupLink" + (new Date()).getTime();
                var G = "";
                if (this.OutputMappings != "") {
                    G = "&OutputParams=" + encodeURI(this.OutputMappings.replace(/,/g, "|").replace(/:/g, ","))
                }
                var C = F.PopupWidth ? F.PopupWidth : "600px";
                var E = F.PopupHeight ? F.PopupHeight : "400px";
                var H = "<div id='" + I + "' class='modal fade' tabindex='-1' role='dialog' aria-hidden='true'>";
                H += "<div class='modal-dialog'>";
                H += "<div class='modal-content' style='width:" + C + ";'>";
                H += "<div class='modal-header'>";
                H += "<button type='button' class='close' data-dismiss='modal'>";
                H += "<span aria-hidden='true'>&times;</span></button>";
                H += "<h4 class='modal-title'>" + B + "</h4>";
                H += "</div><div class='modal-body'>";
                H += "<iframe scrolling='no' frameborder='0' width='100%' height='" + E + "'></iframe>";
                H += "</div></div></div></div>";
                H = A(H);
                var D = A("<a href='javascript:;'>" + B + "</a>");
                D.click(function () {
                    var J = F.PortalRoot + "/ListMasterData.aspx?OpenType=1&IsPopup=1&SchemaCode=" + F.SchemaCode + "&QueryCode=" + F.QueryCode + "&CtrlID=" + I + G + F._getInputParam();
                    H.find("iframe").attr("src", J);
                    H.modal("show")
                });
                A(this.Element).after(D).after(H);
                window[I] = {};
                window[I].ListMasterCallBack = function (K) {
                    if (K) {
                        for (var J in K) {
                            A.MvcSheetUI.SetControlValue(J, K[J], F.RowNum)
                        }
                    }
                    H.modal("hide")
                }
            } else {
                if (this.PopupWindow == "Dropdown") {
                    var I = "popupLink" + (new Date()).getTime();
                    var G = "";
                    if (this.OutputMappings != "") {
                        G = "&OutputParams=" + encodeURI(this.OutputMappings.replace(/,/g, "|").replace(/:/g, ","))
                    }
                    var H = A("<div style='display:none;z-index:9999;position:absolute;background-color:#f8f8f8;' id='" + I + "'><iframe scrolling='no' frameborder='0' width='550px' height='300px'></iframe></div>");
                    A(this.Element).after(H);
                    A(this.Element).unbind("focus.Popup").bind("focus.Popup", function () {
                        var K = F.PortalRoot + "/ListMasterData.aspx?OpenType=1&IsPopup=1&SchemaCode=" + F.SchemaCode + "&QueryCode=" + F.QueryCode + "&CtrlID=" + I + G + F._getInputParam();
                        H.find("iframe").attr("src", K);
                        H.show();
                        var J = A(F.Element).offset();
                        H.offset({top: J.top + A(F.Element).outerHeight() + 3, left: J.left})
                    });
                    window[I] = {};
                    window[I].ListMasterCallBack = function (K) {
                        if (K) {
                            for (var J in K) {
                                A.MvcSheetUI.SetControlValue(J, K[J], F.RowNum)
                            }
                        }
                        H.hide()
                    };
                    A(document).unbind("click." + I).bind("click." + I, function (J) {
                        if (!(A(J.target).attr("type") == "text" && A(J.target).attr(A.MvcSheetUI.PreDataKey + A.MvcSheetUI.DataFieldKey.toLowerCase()) == F.DataField)) {
                            H.hide()
                        }
                    })
                }
            }
        }, _getInputParam: function () {
            var D = "";
            if (this.InputMappings) {
                var C = this.InputMappings.split(",");
                for (var B = 0; B < C.length; B++) {
                    var E = C[B].split(":");
                    if (E && E.length == 2) {
                        if (E[0] && A.MvcSheetUI.GetSheetDataItem(E[0], this.RowNum)) {
                            D += E[1] + "," + A.MvcSheetUI.GetControlValue(E[0], this.RowNum) + "|"
                        }
                    }
                }
                if (D) {
                    D = "&InputParam=" + encodeURI(D.substring(0, D.length - 1))
                }
            }
            return D
        }, SetReadonly: function (D) {
            if (D) {
                A(this.Element).hide();
                var B = A("<label></label>");
                if (this.TextRightAlign) {
                    B.addClass("txtAlignRight").css("width", A(this.Element).width())
                } else {
                    if (this.NumberRightAlign && this.IsNubmer()) {
                        B.addClass("txtAlignRight")
                    }
                }
                var E = A.trim(this.V);
                if (E != "") {
                    var C = E.split("\n");
                    A(C).each(function (F) {
                        if (F > 0) {
                            B.append("<br />")
                        }
                        B.append(A("<span></span>").text(this.toString()))
                    })
                }
                B.insertAfter(A(this.Element));
                this.GetFromatValue(B, this.Element.value)
            } else {
                A(this.Element).show();
                A(this.Element).next().remove()
            }
        }, _OnChange: function (B) {
            this.Validate();
            if (this.OnChange) {
                this.RunScript(this.Element, this.OnChange)
            }
            if (this.AutoTrim) {
                this.Value = that.Value.trim()
            }
        }, Validate: function (B, C) {
            if (!this.Editable) {
                return true
            }
            if (C) {
                if (this.Required && !this.GetValue()) {
                    this.AddInvalidText(this.Element, "*", false);
                    return false
                }
            }
            var D = this.GetValue();
            if (!B) {
                if (A(this.Element).attr("data-required") || this.O.indexOf("R") > -1) {
                    this.Required = true
                } else {
                    this.Required = false
                }
                if (this.Required && !this.DoValidate(this.Valid.Required, [D], "*")) {
                    this.ValidateResult = false;
                    return false
                }
                if (this.RegularExpression && D) {
                    if (!this.DoValidate(this.Valid.RegularExpression, [D, this.RegularExpression], this.RegularInvalidText)) {
                        this.ValidateResult = false;
                        return false
                    }
                }
            }
            switch (this.LogicType) {
                case A.MvcSheetUI.LogicType.Int:
                case A.MvcSheetUI.LogicType.Long:
                    if (!this.DoValidate(this.Valid.Integer, [D], SheetLanguages.Current.EnterInteger)) {
                        this.ValidateResult = false;
                        return false
                    }
                    break;
                case A.MvcSheetUI.LogicType.Double:
                    if (!this.DoValidate(this.Valid.Number, [D], SheetLanguages.Current.EnterNumber)) {
                        this.ValidateResult = false;
                        return false
                    }
                    break;
                default:
                    break
            }
            this.ValidateResult = true;
            return true
        }, SaveDataField: function () {
            var B = {};
            if (!this.Visiable || !this.Editable) {
                return B
            }
            B[this.DataField] = A.MvcSheetUI.GetSheetDataItem(this.DataField);
            if (!B[this.DataField]) {
                if (this.DataField.indexOf(".") == -1) {
                    alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField)
                }
                return {}
            }
            if (("" + B[this.DataField].V) != this.GetValue()) {
                this.RefreshDataTrackLink();
                B[this.DataField].V = this.GetValue().trim();
                return B
            }
            return {}
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetTime = function () {
        return A.MvcSheetUI.Run.call(this, "SheetTime", arguments)
    };
    A.MvcSheetUI.Controls.SheetTime = function (D, B, C) {
        A.MvcSheetUI.Controls.SheetTime.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetTime.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            var E = A(this.Element), D = this.V, F = this;
            if (!this.Visiable) {
                this.Element.style.display = "none";
                return
            }
            var I;
            if (this.Originate && this.Editable) {
                if (D && D != "0001-01-01 00:00:00" && D != "1753-01-01 00:00:00" && D != "9999-12-31 00:00:00") {
                    I = new Date(Date.parse(D.replace(/-/g, "/")))
                } else {
                    if (this.DefaultValue == "CurrentTime") {
                        I = new Date()
                    } else {
                        var B = Date.parse(this.DefaultValue.replace(/-/g, "/"));
                        if (!isNaN(B)) {
                            I = new Date(B)
                        }
                    }
                }
            } else {
                if (D) {
                    if (D == "0001-01-01 00:00:00" || D == "1753-01-01 00:00:00" || D == "9999-12-31 00:00:00") {
                        I = ""
                    } else {
                        I = new Date(Date.parse(D.replace(/-/g, "/")))
                    }
                } else {
                    I = ""
                }
            }
            if (!this.Editable) {
                E.after("<label style='width:100%;'>" + this._getDateTimeFormatString(I).replace(/T/g, " ").replace("/Z/g", "") + "</label>");
                E.hide();
                return
            }
            if (this.IsMobile) {
                var H;
                switch (this.TimeMode) {
                    case "FullTime":
                    case "SimplifiedTime":
                        H = "datetime-local";
                        break;
                    case "OnlyDate":
                        H = "date";
                        break;
                    case "OnlyTime":
                        H = "time";
                        break;
                    default:
                        H = "date";
                        break
                }
                E.attr("type", H);
                var G = window.navigator.userAgent.toLowerCase();
                if (G.match(/MicroMessenger/i) == "micromessenger" && G.toLowerCase().indexOf("android") > -1) {
                }
                this.Element.addEventListener("touchend", function () {
                    event.stopPropagation()
                });
                this.Element.addEventListener("touchstart", function () {
                    event.stopPropagation()
                });
                E.val(this._getDateTimeFormatString(I));
                var F = this;
                E.unbind("change.SheetTime").bind("change.SheetTime", function () {
                    F.Validate();
                    if (F.OnChange) {
                        F.RunScript(this, F.OnChange)
                    }
                })
            } else {
                if (this.TrackVisiable && !this.Originate && this.DataField.indexOf(".") == -1) {
                    this.RenderDataTrackLink()
                }
                E.val(this._getDateTimeFormatString(I));
                E.attr("onclick", "WdatePicker(" + this._getWdatePickerJson() + ")");
                E.attr("onchange", "");
                if (!!window.ActiveXObject || "ActiveXObject" in window) {
                    E[0].onchange = function () {
                        F.Validate();
                        if (F.OnChange) {
                            F.RunScript(this, F.OnChange)
                        }
                    }
                } else {
                    E.unbind("change.SheetTime").bind("change.SheetTime", function () {
                        F.Validate();
                        if (F.OnChange) {
                            F.RunScript(this, F.OnChange)
                        }
                    })
                }
                if (this.MinValue != "CurrentTime" && isNaN(Date.parse(this.MinValue.replace(/-/g, "/")))) {
                    var C = A.MvcSheetUI.GetElement(this.MinValue);
                    if (C) {
                        C.unbind("blur.MinValue").bind("blur.MinValue", function () {
                            E.attr("onclick", "WdatePicker(" + F._getWdatePickerJson() + ")")
                        })
                    }
                }
                if (this.MaxValue != "CurrentTime" && isNaN(Date.parse(this.MaxValue.replace(/-/g, "/")))) {
                    var C = A.MvcSheetUI.GetElement(this.MaxValue);
                    if (C) {
                        C.unbind("blur.MaxValue").bind("blur.MaxValue", function () {
                            E.attr("onclick", "WdatePicker(" + F._getWdatePickerJson() + ")")
                        })
                    }
                }
            }
        }, MobilePreBack: function () {
            if ($dp && typeof ($dp.hide) == "function") {
                $dp.hide()
            }
            return true
        }, _getDateTimeFormatString: function (I) {
            if (!I) {
                return ""
            }
            var D = I.getMonth() + 1 < 10 ? ("0" + (I.getMonth() + 1)) : (I.getMonth() + 1);
            var E = I.getDate() < 10 ? ("0" + I.getDate()) : I.getDate();
            var H = I.getHours() < 10 ? ("0" + I.getHours()) : I.getHours();
            var G = I.getMinutes() < 10 ? ("0" + I.getMinutes()) : I.getMinutes();
            var B = I.getSeconds() < 10 ? ("0" + I.getSeconds()) : I.getSeconds();
            var J = I.getFullYear() + "-" + D + "-" + E;
            var C = H + ":" + G + ":" + B;
            var F = H + ":" + G;
            if (this.IsMobile) {
                switch (this.TimeMode) {
                    case "FullTime":
                    case "SimplifiedTime":
                        return J + "T" + F;
                        break;
                    case "OnlyDate":
                        return J;
                        break;
                    case "OnlyTime":
                        return F;
                        break;
                    default:
                        return J;
                        break
                }
            } else {
                switch (this.TimeMode) {
                    case "OnlyDate":
                        return J;
                        break;
                    case "FullTime":
                        return J + " " + C;
                        break;
                    case "OnlyTime":
                        return C;
                        break;
                    case "SimplifiedTime":
                        return J + " " + F;
                        break;
                    default:
                        return J;
                        break
                }
            }
        }, _getWdatePickerJson: function () {
            if (this.WdatePickerJson != "") {
                return this.WdatePickerJson
            } else {
                var B = "";
                switch (this.TimeMode) {
                    case "OnlyDate":
                        B += "dateFmt:'yyyy-MM-dd'";
                        break;
                    case "FullTime":
                        B += "dateFmt:'yyyy-MM-dd HH:mm:ss'";
                        break;
                    case "OnlyTime":
                        B += "dateFmt:'HH:mm:ss'";
                        break;
                    case "SimplifiedTime":
                        B += "dateFmt:'yyyy-MM-dd HH:mm'";
                        break;
                    default:
                        B += "dateFmt:'yyyy-MM-dd'";
                        break
                }
                var F;
                if (this.MinValue != "") {
                    if (this.MinValue == "CurrentTime") {
                        F = new Date()
                    } else {
                        var C = Date.parse(this.MinValue.replace(/-/g, "/"));
                        if (!isNaN(C)) {
                            F = new Date(C)
                        } else {
                            var D = A(":text[" + A.MvcSheetUI.PreDataKey + A.MvcSheetUI.DataFieldKey.toLowerCase() + "='" + this.MinValue + "']");
                            if (D) {
                                var C = Date.parse(D.val().replace(/-/g, "/"));
                                if (!isNaN(C)) {
                                    F = new Date(C)
                                }
                            }
                        }
                    }
                }
                if (F != undefined) {
                    B += ",minDate:'" + this._getDateTimeFormatString(F) + "'"
                }
                var E;
                if (this.MaxValue != "") {
                    if (this.MaxValue == "CurrentTime") {
                        E = new Date()
                    } else {
                        var C = Date.parse(this.MaxValue.replace(/-/g, "/"));
                        if (!isNaN(C)) {
                            E = new Date(C)
                        } else {
                            var D = A(":text[" + A.MvcSheetUI.PreDataKey + A.MvcSheetUI.DataFieldKey.toLowerCase() + "='" + this.MaxValue + "']");
                            if (D) {
                                var C = Date.parse(D.val().replace(/-/g, "/"));
                                if (!isNaN(C)) {
                                    E = new Date(C)
                                }
                            }
                        }
                    }
                }
                if (E != undefined) {
                    B += ",maxDate:'" + this._getDateTimeFormatString(E) + "'"
                }
                return "{" + B + "}"
            }
        }, GetText: function () {
            return A(this.Element).val().replace(/T/g, " ").replace(/Z/g, "")
        }, SetValue: function (B) {
            if (B) {
                var C = Date.parse(B.replace(/T/g, " ").replace(/-/g, "/"));
                if (!isNaN(C)) {
                    var D = new Date(C);
                    A(this.Element).val(this._getDateTimeFormatString(D))
                }
            }
        }, GetValue: function () {
            var B = null;
            if (this.Editable) {
                B = A(this.Element).val()
            } else {
                B = A(this.Element).siblings("label").html()
            }
            return B
        }, SaveDataField: function () {
            var C = {};
            if (!this.Visiable || !this.Editable) {
                return C
            }
            if (this.DataField) {
                var D = A.MvcSheetUI.GetSheetDataItem(this.DataField);
                if (D) {
                    var B = A(this.Element).val();
                    if (D.V != B) {
                        C[this.DataField] = D;
                        C[this.DataField].V = B
                    }
                } else {
                    if (this.DataField.indexOf(".") == -1) {
                        alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField)
                    }
                }
            }
            return C
        }
    })
})(jQuery);
(function (A) {
    A.fn.SheetTimeSpan = function () {
        return A.MvcSheetUI.Run.call(this, "SheetTimeSpan", arguments)
    };
    A.MvcSheetUI.Controls.SheetTimeSpan = function (D, B, C) {
        A.MvcSheetUI.Controls.SheetTimeSpan.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetTimeSpan.Inherit(A.MvcSheetUI.IControl, {
        Render: function () {
            var B = this;
            $element = A(this.Element);
            if (!this.Visiable) {
                $element.hide();
                return
            }
            if (this.TrackVisiable && !this.Originate && this.DataField.indexOf(".") == -1) {
                this.RenderDataTrackLink()
            }
            var C = this._getTimeSpan(this.V);
            if (this.Editable) {
                this.$dayElement = A("<input type='number' min='0' style='width:58px;height:30px;padding-left:3px;margin:0px 2px 0px 0px' />").val(C.day);
                this.$hourElement = A("<input type='number' min='0' max='23' style='width:39px;height:30px;padding-left:3px;margin:0px 2px 0px 2px;' />").val(C.hour);
                this.$minuteElement = A("<input type='number' min='0' max='59' style='width:39px;height:30px;padding-left:3px;margin:0px 2px 0px 2px' />").val(C.minute);
                this.$secondElement = A("<input type='number' min='0' max='59' style='width:39px;height:30px;padding-left:3px;margin:0px 2px 0px 2px' />").val(C.second);
                $element.append(this.$dayElement, document.createTextNode(SheetLanguages.Current.Day), this.$hourElement, document.createTextNode(SheetLanguages.Current.Hour), this.$minuteElement, document.createTextNode(SheetLanguages.Current.Minute), this.$secondElement, document.createTextNode(SheetLanguages.Current.Second));
                this.$dayElement.unbind("keyup.SheetTimeSpan").bind("keyup.SheetTimeSpan", function (D) {
                    var E = A(this).val();
                    if (!B._isDay(E)) {
                        A(this).val("0");
                        B._focusText(this)
                    }
                });
                this.$hourElement.unbind("keyup.SheetTimeSpan").bind("keyup.SheetTimeSpan", function () {
                    var D = A(this).val();
                    if (!B._isHour(D)) {
                        A(this).val("0");
                        B._focusText(this)
                    }
                });
                this.$minuteElement.unbind("keyup.SheetTimeSpan").bind("keyup.SheetTimeSpan", function () {
                    var D = A(this).val();
                    if (!B._isMinuteOrSecond(D)) {
                        A(this).val("0");
                        B._focusText(this)
                    }
                });
                this.$secondElement.unbind("keyup.SheetTimeSpan").bind("keyup.SheetTimeSpan", function () {
                    var D = A(this).val();
                    if (!B._isMinuteOrSecond(D)) {
                        A(this).val("0");
                        B._focusText(this)
                    }
                });
                $element.find("input").unbind("focus.SheetTimeSpan").bind("focus.SheetTimeSpan", function () {
                    B._focusText(this)
                });
                $element.find("input").unbind("change.SheetTimeSpan").bind("change.SheetTimeSpan", function () {
                    B.Validate();
                    if (B.OnChange) {
                        B.Element.value = B.GetValue();
                        B.RunScript(B.Element, B.OnChange)
                    }
                })
            } else {
                $element.after("<label style='width:100%;'>" + this._getLabelText(C) + "</label>");
                $element.hide()
            }
        }, _focusText: function (B) {
            if (this.IsMobile && A.os.ios) {
                B.setSelectionRange(0, 9999)
            } else {
                A(B).select()
            }
        }, RenderMobile: function () {
            if (this.Editable) {
                this.constructor.Base.RenderMobile.apply(this)
            } else {
                this.Render()
            }
        }, _getTimeSpan: function (C) {
            var F = {};
            if (C) {
                var B = C.indexOf(".");
                var D = C;
                if (B > -1) {
                    F.day = parseInt(C.substring(0, B));
                    D = C.substring(B + 1)
                }
                var E = D.split(":");
                if (E && E.length == 3) {
                    F.hour = parseInt(E[0]);
                    F.minute = parseInt(E[1]);
                    F.second = parseInt(E[2])
                }
            }
            if (!F.day) {
                F.day = 0
            }
            if (!F.hour) {
                F.hour = 0
            }
            if (!F.minute) {
                F.minute = 0
            }
            if (!F.second) {
                F.second = 0
            }
            return F
        }, _isDay: function (B) {
            return /^\d+$/.test(B)
        }, _isHour: function (B) {
            return /^([0-1]?[0-9]|2[0-3])$/.test(B)
        }, _isMinuteOrSecond: function (B) {
            return /^[0-5]?[0-9]$/.test(B)
        }, _getLabelText: function (B) {
            var C = "";
            if (B.day != 0) {
                C = B.day + SheetLanguages.Current.Day + B.hour + SheetLanguages.Current.Hour + B.minute + SheetLanguages.Current.Minute + B.second + SheetLanguages.Current.Second
            } else {
                if (B.hour != 0) {
                    C = B.hour + SheetLanguages.Current.Hour + B.minute + SheetLanguages.Current.Minute + B.second + SheetLanguages.Current.Second
                } else {
                    if (B.minute != 0) {
                        C = B.minute + SheetLanguages.Current.Minute + B.second + SheetLanguages.Current.Second
                    } else {
                        C = B.second + SheetLanguages.Current.Second
                    }
                }
            }
            return C
        }, GetText: function () {
            var B = "";
            var C = this.GetValue();
            if (C) {
                var D = this._getTimeSpan(C);
                return this._getLabelText(D)
            }
            return B
        }, GetValue: function () {
            if (!this.Editable) {
                return this.V
            }
            var D = this.$dayElement.val();
            var C = this.$hourElement.val();
            var E = this.$minuteElement.val();
            var B = this.$secondElement.val();
            if (D || C || E || B) {
                return (D ? D : "0") + "." + (C ? C : "0") + ":" + (E ? E : "0") + ":" + (B ? B : "0")
            } else {
                return null
            }
        }, SetValue: function (B) {
            if (this.Editable) {
                var C = this._getTimeSpan(B);
                if (C) {
                    this.$dayElement.val(C.day);
                    this.$hourElement.val(C.hour);
                    this.$minuteElement.val(C.minute);
                    this.$secondElement.val(C.second)
                }
            }
        }, _isNotEmpty: function () {
            var D = parseInt(this.$dayElement.val());
            var C = parseInt(this.$hourElement.val());
            var E = parseInt(this.$minuteElement.val());
            var B = parseInt(this.$secondElement.val());
            return D || C || E || B
        }, Validate: function (B, C) {
            if (!this.Editable) {
                return true
            }
            if (C) {
                if (this.Required && !this._isNotEmpty()) {
                    this.AddInvalidText(this.Element, "*", false);
                    return false
                }
            }
            if (!B) {
                if (this.Required && !this.DoValidate(this._isNotEmpty, [], "*")) {
                    this.ValidateResult = false;
                    return false
                }
            }
            this.ValidateResult = true;
            return true
        }, SaveDataField: function () {
            var C = {};
            if (!this.Visiable || !this.Editable) {
                return C
            }
            if (this.DataField) {
                var D = A.MvcSheetUI.GetSheetDataItem(this.DataField);
                if (D) {
                    var B = this.GetValue();
                    if (B && D.V != B) {
                        C[this.DataField] = D;
                        C[this.DataField].V = B
                    }
                } else {
                    if (this.DataField.indexOf(".") == -1) {
                        alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField)
                    }
                }
            }
            return C
        }
    })
})(jQuery);
(function () {
    $.fn.SheetToolBar = function () {
        return $.MvcSheetUI.Run.call(this, "SheetToolBar", arguments)
    };
    $.MvcSheetUI.Controls.SheetToolBar = function (C, D, B) {
        this.Element = C;
        this.SheetInfo = B;
        this.ControlManagers = {};
        for (var A in D) {
            this.AddButton(D[A])
        }
        return this
    };
    $.MvcSheetUI.Controls.SheetToolBar.prototype = {
        AddButton: function (B) {
            if (B) {
                var A = B.Action || B.Text;
                if (A == undefined) {
                    return
                }
                if (this.ControlManagers[A]) {
                    return this.ControlManagers[A]
                }
                if ($.MvcSheetToolbar[B.Action]) {
                    this.ControlManagers[B.Action] = new $.MvcSheetToolbar[B.Action](this.Element, B, this.SheetInfo)
                } else {
                    this.ControlManagers[A] = new $.MvcSheetToolbar.IButton(this.Element, B, this.SheetInfo)
                }
            }
        }
    }
})(jQuery);
$.MvcSheetToolbar = {};
$.MvcSheetToolbar.IButton = function (C, D, B) {
    for (var A in D) {
        this[A] = D[A]
    }
    this.ColumnCss = "> .col-md-1,> .col-md-2,> .col-md-3,> .col-md-4,> .col-md-5,> .col-md-6,> .col-md-7,> .col-md-8,> .col-md-9,> .col-md-10,> .col-md-11,> .col-md-12";
    this.CloseAfterAction = D.CloseAfterAction || false;
    this.PostSheetInfo = D.PostSheetInfo || false;
    this.IsMobile = B.IsMobile || ($.MvcSheetUI.QueryString("ismobile") == "true");
    this.OnActionPreDo = D.OnActionPreDo;
    this.OnAction = D.OnAction;
    this.OnActionDone = D.OnActionDone;
    this.CssClass = D.CssClass || "";
    this.Container = C;
    this.SheetInfo = B;
    this.Element = null;
    this.Datas = D.Datas;
    this.Options = D.Options;
    this.PermittedActions = B.PermittedActions;
    this.Visible = this.PermittedActions[this.Action] == undefined ? true : this.PermittedActions[this.Action];
    this.MobileVisible = D.MobileVisible === undefined ? this.Visible : D.MobileVisible;
    this.PreRender();
    this.Render()
};
$.MvcSheetToolbar.IButton.prototype = {
    PreRender: function () {
        var A = this.Text;
        if ($.MvcSheetUI.SheetInfo.Language) {
            A = this[$.MvcSheetUI.SheetInfo.Language] || this.Text
        }
        this.Text = A
    }, Render: function () {
        var A = this.Action || this.Text;
        if (!this.Visible) {
            $(this.Container).children("li[data-action='" + A + "']").hide();
            return
        }
        this.Element = $(this.Container).children("li[data-action='" + A + "']");
        if (this.Element.length == 0) {
            this.Element = this._CreateButtonElement(this.Action, this.Icon, this.Text);
            if (!this.IsMobile) {
                $(this.Container).append(this.Element)
            }
        }
        this.BindClick()
    }, BindClick: function () {
        var A = this.Action || this.Text;
        this.Element.unbind("click." + A).bind("click." + A, this, function (B) {
            B.data.ActionClick.apply(B.data)
        })
    }, _CreateButtonElement: function (A, D, C) {
        var G = $("<li data-action='" + this.Action + "'></li>");
        var F = $("<a href='javascript:void(0);'></a>");
        var E = $("<i class='panel-title-icon fa " + this.Icon + " toolImage'></i>");
        var B = $("<span class='toolText'>" + C + "</span>");
        if (this.CssClass) {
            B.addClass(this.CssClass)
        }
        return G.append(F.append(E).append(B))
    }, ActionClick: function () {
        var A = true;
        if ($.isFunction(this.OnActionPreDo)) {
            A = this.OnActionPreDo.apply(this)
        } else {
            if (this.OnActionPreDo) {
                A = new Function(this.OnActionPreDo).apply(this)
            }
        }
        if (A == null || A == true) {
            this.DoAction.apply(this)
        }
        if (this.OnActionDone) {
            this.OnActionDone.apply(this)
        }
    }, DoAction: function () {
        if (this.OnAction) {
            this.OnAction.apply(this)
        } else {
            if (this.Action) {
                $.MvcSheet.Action(this)
            }
        }
    }, OnActionDone: function () {
    }, FetchUser: function (B, A, E, D, P) {
        var H = this;
        if (!this.SheetUserInited) {
            this.SheetUserInited = true;
            var M = {
                O: "VE",
                L: A ? $.MvcSheetUI.LogicType.MultiParticipant : $.MvcSheetUI.LogicType.SingleParticipant
            };
            if (E) {
                $.extend(M, E)
            }
            var I = $("<div>").SheetUser(M);
            var K = null;
            if (D && !this.SheetInfo.IsMobile) {
                var C = $.MvcSheetUI.NewGuid();
                K = $("<input type='checkbox' id='" + C + "' />");
                K.prop("checked", !!P);
                var G = $("<label for='" + C + "'>" + D + "</label>");
                this.CheckText = K
            }
            if (this.SheetInfo.IsMobile) {
                this.FetchUserPanelID = $.uuid();
                var N = $.uuid();
                var O = $("<header>").attr("id", N);
                O.html("<h1>" + B + '</h1><a class="button icon close" onclick="$.ui.goBack();"></a>');
                O.appendTo("#afui");
                var J = $("<div>").text(SheetLanguages.Current.OK).addClass("button").css("float", "right");
                J.appendTo(O);
                var L = $("<div>").addClass("panel").attr("id", this.FetchUserPanelID).attr("data-header", N).attr("data-transition", "slideUp").attr("data-title", B);
                L.appendTo("#content");
                $(I.Element).appendTo(L);
                if (K) {
                    $(I.Element).after(K);
                    G.width("90%");
                    K.after(G)
                }
                J.click(function () {
                    H.Datas = [];
                    if (I.GetValue()) {
                        H.Datas.push(I.GetValue().toString());
                        if (D) {
                            if (K) {
                                H.Datas.push(K.prop("checked"))
                            } else {
                                H.Datas.push(!!P)
                            }
                        }
                        $.MvcSheet.Action(H);
                        $.ui.goBack();
                        setTimeout(function () {
                            $("#" + N).remove();
                            $("#" + this.FetchUserPanelID).remove()
                        }, 1000)
                    } else {
                        alert(SheetLanguages.Current.SelectUser)
                    }
                })
            } else {
                var F = $("<div><div style='padding-bottom:6px'>" + B + "</div></div>");
                F.css({"min-height": 365, "padding": "10px 20px"}).append(I.Element);
                if (K) {
                    $(I.Element).after($("<div style='padding-top:6px'></div>").append(K).append(G))
                }
                this.ModalManager = new $.SheetModal(B, F, [{
                    Text: SheetLanguages.Current.OK, DoAction: function () {
                        var Q = this.SheetUser.GetValue();
                        this.SheetAction.Datas = [];
                        if (Q) {
                            this.SheetAction.Datas.push(Q.toString());
                            if (this.ChecBoxOjb) {
                                this.SheetAction.Datas.push(this.ChecBoxOjb.prop("checked"))
                            }
                            $.MvcSheet.Action(this.SheetAction);
                            this.ModalManager.Hide()
                        } else {
                            alert(SheetLanguages.Current.SelectUser)
                        }
                    }, SheetUser: I, ChecBoxOjb: K, SheetAction: H
                }, {
                    Text: SheetLanguages.Current.Close, DoAction: function () {
                        this.ModalManager.Hide()
                    }
                }])
            }
        }
        if (this.SheetInfo.IsMobile) {
            $.ui.loadContent("#" + this.FetchUserPanelID)
        } else {
            this.ModalManager.Show()
        }
    }, GetMobileProxy: function (A) {
        return {
            text: A.Text, handler: function () {
                A.ActionClick()
            }
        }
    }
};
$.MvcSheetToolbar.Save = function (C, A, B) {
    return $.MvcSheetToolbar.Save.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.Save.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        $.MvcSheet.Save(this)
    }
});
$.MvcSheetToolbar.ViewInstance = function (C, A, B) {
    return $.MvcSheetToolbar.ViewInstance.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.ViewInstance.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        if (this.SheetInfo.IsMobile) {
            if (!this.SheetInfo.IsOriginateMode) {
                window.open(_PORTALROOT_GLOBAL + "/Mobile/InstanceState.aspx?InstanceId=" + this.SheetInfo.InstanceId + "&WorkItemID=" + this.SheetInfo.WorkItemId, "_self")
            } else {
                window.open(_PORTALROOT_GLOBAL + "/Mobile/InstanceState.aspx?WorkflowCode=" + this.SheetInfo.WorkflowCode + "&WorkflowVersion=" + this.SheetInfo.WorkflowVersion, "_self")
            }
        } else {
            if (!this.SheetInfo.IsOriginateMode) {
                window.open(_PORTALROOT_GLOBAL + "/InstanceDetail.aspx?InstanceId=" + this.SheetInfo.InstanceId + "&WorkItemID=" + this.SheetInfo.WorkItemId, "_blank")
            } else {
                window.open(_PORTALROOT_GLOBAL + "/WorkflowInfo.aspx?WorkflowCode=" + this.SheetInfo.WorkflowCode + "&WorkflowVersion=" + this.SheetInfo.WorkflowVersion)
            }
        }
    }
});
$.MvcSheetToolbar.PreviewParticipant = function (C, A, B) {
    return $.MvcSheetToolbar.PreviewParticipant.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.PreviewParticipant.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        this.constructor.Base.DoAction(this)
    }
});
$.MvcSheetToolbar.CancelInstance = function (C, A, B) {
    return $.MvcSheetToolbar.CancelInstance.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.CancelInstance.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        var A = this;
        $.MvcSheet.ConfirmAction(SheetLanguages.Current.ConfirmCancelInstance, function () {
            $.MvcSheet.Action(A)
        })
    }
});
$.MvcSheetToolbar.Reject = function (C, A, B) {
    return $.MvcSheetToolbar.Reject.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.Reject.Inherit($.MvcSheetToolbar.IButton, {
    Render: function () {
        if (!this.Visible) {
            var E = this.Action || this.Text;
            $(this.Container).children("li[data-action='" + E + "']").hide();
            return
        }
        if (this.SheetInfo.ApprovalListVisible) {
            this.Text = SheetLanguages.Current.Disagree
        }
        var D = [];
        if (this.SheetInfo.RejectActivities) {
            for (var A = 0; A < this.SheetInfo.RejectActivities.length; ++A) {
                D.push({
                    Action: this.SheetInfo.RejectActivities[A].Code,
                    Icon: this.Icon,
                    Text: this.SheetInfo.RejectActivities[A].Name,
                    OnAction: function () {
                        $.MvcSheet.Reject(this, this.Action)
                    },
                    MobileVisible: false
                })
            }
        }
        if (D.length > 0) {
            if (D.length == 1) {
                this.Text = D[0].Text;
                this.DestActivity = D[0].Action;
                this.constructor.Base.Render.apply(this)
            } else {
                this.constructor.Base.Render.apply(this);
                this.DropdownMenu = $("<ul class='dropdown-menu'></ul>");
                var C = this.DropdownMenu.SheetToolBar(D);
                if (this.IsMobile) {
                    this.MobileActions = [];
                    for (_Action in C.ControlManagers) {
                        var B = C.ControlManagers[_Action];
                        this.MobileActions.push(this.GetMobileProxy(B))
                    }
                }
                this.Element.append(this.DropdownMenu);
                this.OnActionPreDo = null
            }
        } else {
            this.constructor.Base.Render.apply(this)
        }
    }, DoAction: function () {
        if (this.DropdownMenu) {
            if (this.IsMobile) {
                $.ui.actionsheet(this.MobileActions)
            } else {
                if (this.DropdownMenu.is(":hidden")) {
                    this.DropdownMenu.show()
                } else {
                    this.DropdownMenu.hide()
                }
            }
        } else {
            if (this.DestActivity) {
                $.MvcSheet.Reject(this, this.DestActivity)
            } else {
                $.MvcSheet.Reject(this)
            }
        }
    }
});
$.MvcSheetToolbar.Submit = function (C, A, B) {
    return $.MvcSheetToolbar.Submit.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.Submit.Inherit($.MvcSheetToolbar.IButton, {
    Render: function () {
        var E = false, B = false;
        if (!this.Visible) {
            var F = this.Action || this.Text;
            $(this.Container).children("li[data-action='" + F + "']").hide();
            return
        }
        if (this.SheetInfo.ApprovalListVisible) {
            this.Text = SheetLanguages.Current.Agree
        }
        this.SubmitActivities = [];
        if (this.SheetInfo.SubmitActivities == null || this.SheetInfo.SubmitActivities == undefined || this.SheetInfo.SubmitActivities.length == 0) {
            if (this.SheetInfo.Posts) {
                E = this.SheetInfo.Posts.length > 1;
                for (var G = 0; G < this.SheetInfo.Posts.length; G++) {
                    this.SubmitActivities.push({
                        Action: this.Action + "&" + this.SheetInfo.Posts[G].Code,
                        Icon: this.Icon,
                        Text: this.Text + (E ? ("-" + this.SheetInfo.Posts[G].Name) : ""),
                        OnAction: function () {
                            $.MvcSheet.Submit(this, this.Text, "", this.Action.split("&")[1])
                        },
                        MobileVisible: false
                    })
                }
            }
            if (this.SheetInfo.Groups) {
                B = this.SheetInfo.Groups.length > 1;
                for (var G = 0; G < this.SheetInfo.Groups.length; G++) {
                    this.SubmitActivities.push({
                        Action: this.Action + "&" + this.SheetInfo.Groups[G].Code,
                        Icon: this.Icon,
                        Text: this.Text + (B ? ("-" + this.SheetInfo.Groups[G].Name) : ""),
                        OnAction: function () {
                            $.MvcSheet.Submit(this, this.Text, "", null, this.Action.split("&")[1])
                        },
                        MobileVisible: false
                    })
                }
            }
        } else {
            for (var A = 0; A < this.SheetInfo.SubmitActivities.length; ++A) {
                this.SubmitActivities.push({
                    Action: this.SheetInfo.SubmitActivities[A].Code,
                    Text: this.Text + "-" + this.SheetInfo.SubmitActivities[A].Name,
                    OnAction: function () {
                        $.MvcSheet.Submit(this, this.Text, this.Action)
                    },
                    MobileVisible: false
                });
                if (this.SheetInfo.Posts) {
                    E = this.SheetInfo.Posts.length > 1;
                    for (var G = 0; G < this.SheetInfo.Posts.length; G++) {
                        this.SubmitActivities.push({
                            Action: this.SheetInfo.SubmitActivities[A].Code + "&" + this.SheetInfo.Posts[G].Code,
                            Icon: this.Icon,
                            Text: this.Text + "-" + this.SheetInfo.SubmitActivities[A].Name + (E ? ("-" + this.SheetInfo.Posts[G].Name) : ""),
                            OnAction: function () {
                                $.MvcSheet.Submit(this, this.Text, this.Action.split("&")[0], this.Action.split("&")[1])
                            },
                            MobileVisible: false
                        })
                    }
                }
                if (this.SheetInfo.Groups) {
                    B = this.SheetInfo.Groups.length > 1;
                    for (var G = 0; G < this.SheetInfo.Groups.length; G++) {
                        this.SubmitActivities.push({
                            Action: this.SheetInfo.SubmitActivities[A].Code + "&" + this.SheetInfo.Groups[G].Code,
                            Icon: this.Icon,
                            Text: this.Text + "-" + this.SheetInfo.SubmitActivities[A].Name + (B ? ("-" + this.SheetInfo.Groups[G].Name) : ""),
                            OnAction: function () {
                                $.MvcSheet.Submit(this, this.Text, this.Action.split("&")[0], null, this.Action.split("&")[1])
                            },
                            MobileVisible: false
                        })
                    }
                }
            }
        }
        if (this.SubmitActivities.length > 1) {
            this.constructor.Base.Render.apply(this);
            this.DropdownMenu = $("<ul class='dropdown-menu'></ul>");
            var C = this.DropdownMenu.SheetToolBar(this.SubmitActivities);
            if (this.IsMobile) {
                this.MobileActions = [];
                for (_Action in C.ControlManagers) {
                    var D = C.ControlManagers[_Action];
                    this.MobileActions.push(this.GetMobileProxy(D))
                }
            }
            $(this.Element).append(this.DropdownMenu);
            this.OnActionPreDo = null
        } else {
            if (this.SubmitActivities.length == 1) {
                this.Text = this.SubmitActivities[0].Text;
                this.constructor.Base.Render.apply(this)
            } else {
                this.constructor.Base.Render.apply(this)
            }
        }
    }, DoAction: function () {
        if (this.SubmitActivities.length == 1) {
            this.SubmitActivities[0].OnAction.apply(this.SubmitActivities[0]);
            return
        }
        if (this.DropdownMenu) {
            if (this.IsMobile) {
                $.ui.actionsheet(this.MobileActions)
            } else {
                if (this.DropdownMenu.is(":hidden")) {
                    this.DropdownMenu.show()
                } else {
                    this.DropdownMenu.hide()
                }
            }
        } else {
            $.MvcSheet.Submit(this, this.Text)
        }
    }
});
$.MvcSheetToolbar.FinishInstance = function (C, A, B) {
    return $.MvcSheetToolbar.FinishInstance.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.FinishInstance.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        $.MvcSheet.ConfirmAction(SheetLanguages.Current.ConfirmFinishInstance, function () {
            $.MvcSheet.FinishInstance(this)
        })
    }
});
$.MvcSheetToolbar.Forward = function (C, A, B) {
    return $.MvcSheetToolbar.Forward.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.Forward.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        if (this.SheetInfo.WorkItemType == -1) {
            return
        } else {
            var A = undefined;
            if (this.SheetInfo.OptionalRecipients) {
                A = this.SheetInfo.OptionalRecipients[this.Action]
            }
            this.FetchUser.apply(this, [SheetLanguages.Current.SelectForwardUser, false, A])
        }
    }
});
$.MvcSheetToolbar.Assist = function (C, A, B) {
    return $.MvcSheetToolbar.Assist.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.Assist.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        if (this.SheetInfo.WorkItemType == -1) {
            return
        } else {
            var A = {GroupVisible: true, PostVisible: true};
            if (this.SheetInfo.OptionalRecipients && this.SheetInfo.OptionalRecipients[this.Action]) {
                A = this.SheetInfo.OptionalRecipients[this.Action]
            }
            this.FetchUser.apply(this, [SheetLanguages.Current.SelectAssistUser, true, A, SheetLanguages.Current.AssistRemind])
        }
    }
});
$.MvcSheetToolbar.Consult = function (C, A, B) {
    return $.MvcSheetToolbar.Consult.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.Consult.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        if (this.SheetInfo.WorkItemType == -1) {
            return
        } else {
            var A = {GroupVisible: true, PostVisible: true};
            if (this.SheetInfo.OptionalRecipients && this.SheetInfo.OptionalRecipients[this.Action]) {
                A = this.SheetInfo.OptionalRecipients[this.Action]
            }
            this.FetchUser.apply(this, [SheetLanguages.Current.SelectConsultUser, true, A, SheetLanguages.Current.ConsultRemind])
        }
    }
});
$.MvcSheetToolbar.Circulate = function (C, A, B) {
    return $.MvcSheetToolbar.Circulate.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.Circulate.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        if (this.SheetInfo.WorkItemType == -1) {
            return
        } else {
            var A = {
                SegmentVisible: true,
                OrgUnitVisible: true,
                GroupVisible: true,
                PostVisible: true,
                UserVisible: true
            };
            if (this.SheetInfo.OptionalRecipients && this.SheetInfo.OptionalRecipients[this.Action]) {
                A = this.SheetInfo.OptionalRecipients[this.Action]
            }
            this.FetchUser.apply(this, [SheetLanguages.Current.SelectCirculateUser, true, A, SheetLanguages.Current.AllowCirculate, true])
        }
    }
});
$.MvcSheetToolbar.AdjustParticipant = function (C, A, B) {
    return $.MvcSheetToolbar.AdjustParticipant.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.AdjustParticipant.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        if (this.SheetInfo.WorkItemType == -1) {
            return
        } else {
            this.FetchUser.apply(this, [SheetLanguages.Current.SelectSignUser, true])
        }
    }
});
$.MvcSheetToolbar.Close = function (C, A, B) {
    return $.MvcSheetToolbar.Close.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.Close.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        $.MvcSheet.ConfirmAction(SheetLanguages.Current.ConfrimClose, function () {
            $.MvcSheet.ClosePage(this)
        })
    }
});
$.MvcSheetToolbar.Print = function (C, A, B) {
    this.Printed = false;
    return $.MvcSheetToolbar.Print.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.Print.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        if (this.SheetInfo.PrintUrl) {
            window.open(this.SheetInfo.PrintUrl)
        } else {
            window.print()
        }
    }
});
$.MvcSheetToolbar.RetrieveInstance = function (C, A, B) {
    return $.MvcSheetToolbar.RetrieveInstance.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.RetrieveInstance.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        $.MvcSheet.ConfirmAction(SheetLanguages.Current.ConfirmReterive, function () {
            $.MvcSheet.RetrieveInstance(this)
        })
    }
});
$.MvcSheetToolbar.Viewed = function (C, A, B) {
    return $.MvcSheetToolbar.Viewed.Base.constructor.call(this, C, A, B)
};
$.MvcSheetToolbar.Viewed.Inherit($.MvcSheetToolbar.IButton, {
    DoAction: function () {
        $.MvcSheet.Submit(this, this.Text)
    }
});
(function (A) {
    A.fn.SheetUser = function () {
        return A.MvcSheetUI.Run.call(this, "SheetUser", arguments)
    };
    A.MvcSheetUI.Controls.SheetUser = function (D, B, C) {
        this.Choices = {};
        this.ChoicesElement = null;
        this.SearchElement = null;
        this.SearchTxtElement = null;
        this.SearchButton = null;
        this.SelectedValue = null;
        this.SearchKey = null;
        this.SearchMode = false;
        this.KeyTime = null;
        this.SearchResults = [];
        this.SelectorPanel = null;
        this.EnterSearch = true;
        this.OrgTreePanel = null;
        this.OrgListPanel = null;
        this.IsOverSelectorPanel = false;
        this.SheetUserHandler = _PORTALROOT_GLOBAL + "/Ajax/SheetUserHandler.ashx";
        A.MvcSheetUI.Controls.SheetUser.Base.constructor.call(this, D, B, C)
    };
    A.MvcSheetUI.Controls.SheetUser.Inherit(A.MvcSheetUI.IControl, {
        RenderMobile: function () {
            this.IsMultiple = this.LogicType == A.MvcSheetUI.LogicType.MultiParticipant;
            if (!this.Editable) {
                A(this.Element).prop("readonly", true);
                A(this.Element).addClass(this.Css.Readonly);
                A(this.Element).addClass("item-content")
            } else {
                this.MobileHtmlRender();
                this.MoveToMobileContainer()
            }
            this.InitValue();
            if (!this.EditPanel) {
                this.EditPanel = A("<div>").attr("id", A.uuid()).attr("data-title", this.Title).attr("data-footer", "none").addClass("panel").appendTo("#content")
            }
            A(this.EditPanel).addClass("no-scroll");
            this.SetMobilePanelRefreshOnload(A(this.EditPanel).attr("id"))
        }, Render: function () {
            if (!this.Visiable) {
                this.Element.style.display = "none";
                return
            }
            if (this.TrackVisiable && !this.Originate && this.DataField.indexOf(".") == -1) {
                this.RenderDataTrackLink()
            }
            this.IsMultiple = this.LogicType == A.MvcSheetUI.LogicType.MultiParticipant;
            if (!this.Editable) {
                A(this.Element).prop("readonly", true);
                A(this.Element).addClass(this.Css.Readonly);
                A(this.Element).css("padding-top", "6px")
            } else {
                this.ClearChoices();
                this.IsLoaded = false;
                this.SelectedValue = "";
                this.__QueryOptions = "";
                this.HtmlRender();
                this.BindEnvens()
            }
            this.InitValue()
        }, InitValue: function () {
            if (this.SheetInfo.IsOriginateMode && !this.V && this.DefaultValue) {
                this.V = this.DefaultValue;
                if (this.V.constructor == String) {
                    if (this.V.toLowerCase() == "originator" || this.V.toLowerCase() == "{originator}") {
                        this.V = this.SheetInfo.Originator
                    } else {
                        if (this.V.toLowerCase() == "{originator.ou}" || this.V.toLowerCase() == "originator.ou") {
                            this.V = this.SheetInfo.OriginatorOU
                        }
                    }
                }
            }
            this.SetValue(this.V);
            if (this.IsMobile) {
                if (this.Editable) {
                    this.Mask.html(this.GetText())
                } else {
                    A(this.Elment).html(this.GetText())
                }
            }
        }, SetRootUnit: function (B) {
            this.RootUnit = B;
            this.TreeManager.clear();
            this.TreeManager.loadData(null, this.SheetUserHandler + "?ParentCode=" + this.RootUnit)
        }, SetValue: function (B) {
            if (B == undefined || B == null || B == "") {
                return
            }
            if (B.constructor == Object) {
                this.AddChoice({ObjectID: B.Code, Name: B.Name})
            } else {
                if (B.constructor == Array) {
                    for (var C = 0; C < B.length; C++) {
                        if (B[C].constructor == Object) {
                            this.AddChoice({ObjectID: B[C].Code, Name: B[C].Name})
                        } else {
                            if (B[C].constructor == String) {
                                this.AddUserID(B[C]);
                                if (!this.IsMultiple) {
                                    break
                                }
                            }
                        }
                    }
                } else {
                    if (B.constructor == String) {
                        this.AddUserID(B)
                    }
                }
            }
        }, GetValue: function () {
            var C;
            for (var B in this.Choices) {
                if (this.IsMultiple) {
                    if (C == undefined) {
                        C = new Array()
                    }
                    C.push(B)
                } else {
                    C = B
                }
            }
            return C == undefined ? "" : C
        }, GetText: function () {
            var B;
            for (var C in this.Choices) {
                if (this.IsMultiple) {
                    if (B == undefined) {
                        B = new Array()
                    }
                    B.push(this.Choices[C].Name)
                } else {
                    B = this.Choices[C].Name
                }
            }
            return B == undefined ? "" : B.toString()
        }, SaveDataField: function () {
            var B = {};
            if (!this.Visiable || !this.Editable) {
                return B
            }
            B[this.DataField] = this.DataItem;
            if (!B[this.DataField]) {
                if (this.DataField.indexOf(".") == -1) {
                    alert(SheetLanguages.Current.DataItemNotExists + ":" + this.DataField)
                }
                return {}
            }
            var C = this.GetValue();
            if (B[this.DataField].V != C) {
                B[this.DataField].V = C;
                return B
            }
            return {}
        }, HtmlRender: function () {
            this.ID = A(this.Element).attr("ID") || A.MvcSheetUI.NewGuid();
            A(this.Element).attr("ID", this.ID);
            A(this.Element).css("z-index", "inherit");
            A(this.Element).addClass("select2-container select2-container-multi ").attr("data-sheetusercontrol", true);
            A(this.Element).css("min-width", "150px");
            if (this.ChoicesElement == null) {
                this.ChoicesElement = A("<ul>").addClass("select2-choices").css("overflow", "hidden");
                this.SearchElement = A("<li>").addClass("select2-search-field");
                this.SearchTxtElement = A("<input>").addClass("form-control").addClass("no-padding");
                this.SearchTxtElement.width("1px");
                this.SearchElement.append(this.SearchTxtElement);
                this.ChoicesElement.append(this.SearchElement);
                A(this.Element).append(this.ChoicesElement)
            }
            this.SetSearchTxtElementWidth.apply(this);
            if (!this.Editable) {
                A(this.SearchTxtElement).prop("readonly", true);
                A(this.SearchElement).width("100%");
                A(this.SearchElement).addClass(this.Css.Readonly);
                this.SearchTxtElement.closest("ul").css("border", "0px");
                this.SearchTxtElement.width("100%");
                return
            }
            if (this.SelectorPanel == null) {
                this.SelectorPanel = A("<div>").addClass("bordered").css("position", "absolute").css("z-index", "888").css("overflow", "auto").width("100%").css("min-width", "430px").css("height", "300px").css("display", "none").css("background-color", "#FFFFFF").css("left", "0").attr("data-SheetUserPanel", "SelectorPanel");
                this.OrgTreePanel = A("<div>").css("max-width", "60%").addClass("bordered").css("float", "left").height("100%").css("overflow", "scroll");
                this.SelectorPanel.append(this.OrgTreePanel);
                this.OrgListPanel = A("<div>").height("100%").css("overflow", "auto");
                this.SelectorPanel.append(this.OrgListPanel);
                A(this.Element).append(this.SelectorPanel)
            }
            if (!this.Recursive || this.RoleName || this.OrgJobCode || this.OrgPostCode || this.OrgCode) {
                this.OrgTreePanel.hide();
                this.SelectorPanel.css("min-width", "0px")
            } else {
                this.OrgTreePanel.show();
                this.SelectorPanel.css("min-width", "430px")
            }
        }, MobileHtmlRender: function () {
            this.Level = 0;
            this.ID = A.MvcSheetUI.NewGuid();
            A(this.Element).attr("ID", this.ID);
            this.ChoicesPanel = A("<div></div>").addClass("select2-container").addClass("scroll-wrapper").css({
                "background-color": "white",
                position: "relative",
                "min-height": "37px",
                "max-height": "110px",
                width: "100%"
            });
            this.ChoicesElement = A("<ul>").addClass("select2-choices").addClass("scroller").css({
                width: "100%",
                overflow: "hidden",
                "min-height": "35px"
            });
            this.ChoicesPanel.append(this.ChoicesElement);
            A(this.Element).append(this.ChoicesPanel);
            this.SearchElement = A("<li>").addClass("select2-search-field").css({width: "100%"});
            this.SearchTxtElement = A("<input>").attr("placeholder", "搜索").css({
                width: "85%",
                height: "40px",
                "padding-left": "10px",
                "padding-right": "10px",
                "font-size": "14px"
            });
            this.SearchElement.append(this.SearchTxtElement);
            if (this.VisibleUnits) {
                this.SearchElement.hide()
            }
            this.SearchButton = A("<a>").attr("data-ignore", "true").addClass("button icon magnifier big").css({
                border: "none",
                margin: 0,
                padding: "12px",
                width: "15%"
            });
            this.SearchElement.append(this.SearchButton);
            A(this.Element).append(A("<ul>").width("100%").append(this.SearchElement));
            this.OrgListPanel = A("<ul>").width("100%").addClass("list");
            this.SelectorPanel = A("<div>").attr("id", A.uuid()).addClass("list").addClass("scroll-wrapper").width("100%").css("position", "relative");
            A(this.SelectorPanel).bind("touchstart", function () {
                C.SearchTxtElement.blur()
            });
            this.SelectorPanel.append(this.OrgListPanel);
            A(this.Element).append(this.SelectorPanel);
            this.FooterID = A.uuid();
            var E = A("<footer id=" + this.FooterID + " ><a class='icon left'>返回</a><footer>");
            A("#afui").append(E);
            A(E).unbind("click.footerObj").bind("click.footerObj", this, function (F) {
                A.ui.goBack(F.data.Level);
                F.data.Level = 0;
                F.data.Validate()
            });
            var C = this;
            if (this.VisibleUnits && this.VisibleUnits.length) {
                this.OrgListPanel;
                var D = this.GetLoadTreeOption();
                if (this.VisibleUnits.split(";").length > 1) {
                    var B = this.SheetUserHandler + "?IsMobile=true&" + D;
                    A.ajax({
                        url: B, dataType: "json", success: function (F) {
                            C.AddMobileOptions(F, C.OrgListPanel)
                        }, error: function (F) {
                            console.log(F)
                        }
                    })
                } else {
                    var B = this.SheetUserHandler + "?IsMobile=true&ParentID=" + this.VisibleUnits + "&" + D;
                    A.ajax({
                        url: B, dataType: "json", success: function (F) {
                            C.AddMobileOptions(F, C.OrgListPanel)
                        }, error: function (F) {
                            console.log(F)
                        }
                    })
                }
            } else {
                this.OrgListBtn = A("<li>").data("targetID", A.uuid()).text("从组织架构选择").addClass("selectFromOrg").css({
                    "border-top": "1px solid #ccc",
                    height: "40px",
                    top: "0px",
                    right: "0px",
                    padding: "10px",
                    cursor: "pointer",
                    "border-bottom": "1px solid #eeeeee"
                });
                this.OrgListBtn.insertAfter(this.SearchElement);
                A(this.SearchTxtElement).unbind("keydown.SearchTxtElement").bind("keydown.SearchTxtElement", this, function (F) {
                    if (F.which == 13) {
                        F.preventDefault();
                        F.stopPropagation()
                    }
                });
                A(this.SearchButton).unbind("click.SearchTxtElement").bind("click.SearchTxtElement", this, function (F) {
                    F.data.SearchOrg.apply(F.data.SearchTxtElement, [F.data])
                });
                A(this.OrgListBtn).unbind("click.OrgListBtn").bind("click.OrgListBtn", this, function (F) {
                    var G = A(this).data("targetID");
                    F.data.AddMobilePanel.apply(F.data, [G, ""])
                })
            }
        }, BindEnvens: function () {
            if (!this.Editable) {
                return
            }
            A(this.ChoicesElement).unbind("click.SheetUser").bind("click.SheetUser", this, function (C) {
                C.data.SearchTxtElement.focus()
            });
            A(this.SearchTxtElement).unbind("focusin.SearchTxtElement").bind("focusin.SearchTxtElement", this, function (C) {
                C.data.FocusInput.apply(C.data)
            });
            if (!this.Recursive) {
                var B = this;
                A.ajax({
                    type: "GET",
                    url: this.SheetUserHandler + "?Recursive=false&ParentCode=" + this.RootUnit + "&" + this.GetLoadTreeOption(),
                    dataType: "json",
                    success: function (D) {
                        for (var C = 0; C < D.length; ++C) {
                            B.AddListItem.apply(B, [D[C]])
                        }
                    }
                });
                if (this.IsMobile) {
                } else {
                    A(document).unbind("click." + this.ID).bind("click." + this.ID, this, function (C) {
                        if (A(C.target).closest("div[id='" + C.data.ID + "']").length == 0) {
                            C.data.FocusOutput.apply(C.data)
                        }
                    })
                }
                A(this.SearchTxtElement).prop("readonly", "readonly");
                return
            }
            if (this.IsMobile) {
                A(this.SearchTxtElement).unbind("keydown.SearchTxtElement").bind("keydown.SearchTxtElement", this, function (C) {
                    if (C.which == 13) {
                        C.preventDefault();
                        C.stopPropagation()
                    }
                });
                A(this.SearchTxtElement).unbind("keyup.SearchTxtElement").bind("keyup.SearchTxtElement", this, function (C) {
                    if (C.which == 13) {
                        C.data.SetSearchTxtElementWidth.apply(C.data);
                        C.data.FocusInput.apply(C.data);
                        C.data.SearchOrg.apply(C.data, [C.data])
                    }
                })
            } else {
                A(this.SearchTxtElement).unbind("keyup.SearchTxtElement").bind("keyup.SearchTxtElement", this, function (C) {
                    C.data.SetSearchTxtElementWidth.apply(C.data);
                    C.data.FocusInput.apply(C.data);
                    C.data.KeyTime = new Date();
                    var D = C.data;
                    setTimeout(function () {
                        D.SearchOrg.apply(D, [D])
                    }, 500)
                });
                A(this.SearchTxtElement).unbind("keydown.SearchTxtElement").bind("keydown.SearchTxtElement", this, function (C) {
                    if (C.keyCode == 8 && A(this).val() == "") {
                        C.data.RemoveChoice.apply(C.data, [A(this).parent().prev().attr("data-code")])
                    }
                })
            }
            A(document).unbind("click." + this.ID).bind("click." + this.ID, this, function (C) {
                if (A(C.target).closest("div[id='" + C.data.ID + "']").length == 0) {
                    C.data.FocusOutput.apply(C.data)
                }
            });
            if (this.IsMobile) {
                A(this.OrgListBtn).unbind("click.OrgListBtn").bind("click.OrgListBtn", this, function (C) {
                    var D = A(this).data("targetID");
                    C.data.AddMobilePanel.apply(C.data, [D, ""])
                })
            }
        }, AddMobilePanel: function (G, E) {
            this.Level++;
            var D = this;
            var F = A("#" + G);
            if (F.length == 0) {
                F = A("<div>").attr("id", G).addClass("panel").addClass("no-scroll").hide();
                if (E != "") {
                    var B = A("li[objectID='" + E + "']>label");
                    if (B.length == 0) {
                        B = A("li[objectID='" + E + "']")
                    }
                    F.attr("data-title", B.text())
                } else {
                    F.attr("data-title", A.ui.prevHeader.find("#pageTitle").text())
                }
                F.attr("data-footer", this.FooterID);
                F.data("parentid", E);
                var C = D.SheetUserHandler + "?IsMobile=true&ParentCode=" + this.RootUnit + "&" + D.GetLoadTreeOption();
                if (E) {
                    C = D.SheetUserHandler + "?IsMobile=true&ParentID=" + E
                }
                A.ajax({
                    type: "GET", url: C, dataType: "json", context: D, async: false, success: function (J) {
                        var I = A("<ul>").addClass("orglist").addClass("list");
                        D.AddMobileOptions(J, I);
                        var H = A("<div class='scroll-wrapper'>");
                        H.append(I);
                        F.append(H);
                        A("#content").append(F);
                        D.SetMobilePanelRefreshOnload(G)
                    }
                })
            }
            A.ui.loadContent(G);
            this.MobileFindCheckbox(G)
        }, MobilePreBack: function () {
            var B = "#" + A.ui.activeDiv.id;
            if (this.Level > 0) {
                this.Level--
            }
            this.MobileFindCheckbox(B)
        }, SetMobilePanelRefreshOnload: function (B) {
            var C = this;
            window.PanelLoadActions = window.PanelLoadActions || {};
            var C = this;
            var D = "F" + this.EditPanel.attr("id").replace(/\-/g, "");
            A("#" + B).attr("data-load", "window.PanelLoadActions." + D);
            window.PanelLoadActions[D] = function () {
                setTimeout(function () {
                    C.RefreshMobilePage()
                }, 600)
            }
        }, AddMobileOptions: function (E, D, C) {
            if (E) {
                var B = this;
                if (E instanceof Array) {
                    if (E.length) {
                        A(E).each(function () {
                            B._AddMobileOption(this, D, C)
                        })
                    } else {
                        D.html('<li class="user-item">没有任何组织</li>')
                    }
                } else {
                    B._AddMobileOption(E, D, C)
                }
            } else {
                D.html('<li class="user-item">没有任何组织</li>')
            }
        }, GetSelectableFlag: function () {
            if (typeof (this.__SelectableOption) == "undefined") {
                this.__SelectableOption = "";
                loadOptions = this.GetLoadTreeOption();
                var B = loadOptions.match(/o=[A-z]*/);
                if (B && B.length) {
                    this.__SelectableOption = B[0].replace("o=", "")
                }
            }
            return this.__SelectableOption
        }, _AddMobileOption: function (I, J, B) {
            var F = this.GetSelectableFlag();
            var G = A("<li>").addClass("user-item");
            if (F.indexOf(I.ExtendObject.UnitType) > -1) {
                var L = A.uuid();
                var E = A("<input type='checkbox'  id='" + L + "' data-objectid='" + I.ObjectID + "'/>");
                E.attr("checked", this.Choices && this.Choices[I.ObjectID] != undefined);
                G.append(E);
                var C = I.Text;
                if (B) {
                    C.replace(B, "<span class='bg-info'>" + B + "</span>")
                }
                G.append(A("<label type='checkbox' label-for='" + L + "'>" + C + "</label>").css("float", "none").css("left", "25px"))
            } else {
                G.append(I.Text)
            }
            G.attr("objectID", I.ObjectID);
            var K = A.uuid();
            G.attr("targetID", K);
            if (!I.IsLeaf) {
                var D = A("<a data-ignore=true>" + A(G).html() + "</a>");
                A(G).html("").append(D);
                G.append(A("<div>").addClass("org-expand").css({
                    width: "20%",
                    height: "100%",
                    "z-index": 2,
                    position: "absolute",
                    right: 0,
                    top: 0
                }))
            }
            J.append(G);
            var H = {ObjectID: I.ObjectID, Name: I.Text};
            A(G).unbind("click.OrgListBtn").bind("click.OrgListBtn", [this, H], function (M) {
                var P = M.data[0];
                var N = M.data[1];
                if (A(M.target).is(".org-expand") || A(this).find("input[type=checkbox]").length == 0) {
                    var Q = A(this).attr("objectID");
                    var R = A(this).attr("targetID");
                    A("#defaultHeader>.backButton").data("pannelid", K);
                    P.AddMobilePanel.apply(P, [R, Q])
                } else {
                    var O = A(this).find("input[type=checkbox]");
                    O.prop("checked", !O.prop("checked"));
                    P.UnitCheckboxClick.apply(A(this).find("input[type=checkbox]").get(0), M.data)
                }
            })
        }, MobileFindCheckbox: function (C) {
            if (C == undefined && A.ui.history) {
                C = A.ui.history[A.ui.history.length - 1].target
            }
            if (C.indexOf("#") < 0) {
                C = "#" + C
            }
            var B = this;
            A(C).find("input:checkbox").each(function () {
                A(this).prop("checked", B.Choices[A(this).attr("data-objectid")] != undefined)
            })
        }, SetSearchTxtElementWidth: function () {
            if (this.IsMobile) {
                return
            }
            var C = "1px";
            var B = this.SearchTxtElement.val().length;
            if (B > 0) {
                C = B * 15 + "px";
                this.SearchTxtElement.removeAttr("PlaceHolder", this.PlaceHolder)
            } else {
                if (A.isEmptyObject(this.Choices)) {
                    C = "100%";
                    this.SearchTxtElement.attr("PlaceHolder", this.PlaceHolder)
                } else {
                    this.SearchTxtElement.removeAttr("PlaceHolder", this.PlaceHolder)
                }
            }
            A(this.SearchTxtElement).width(C);
            if (this.IsMobile) {
            }
        }, FocusInput: function () {
            if (this.IsMobile) {
                return
            }
            if (this.SelectorPanel.is(":visible")) {
                return
            }
            A("div[data-SheetUserPanel='SelectorPanel']").hide();
            this.SelectorPanel.show();
            if (!this.IsMobile && !this.IsLoaded) {
                this.LoadOrgTree()
            }
            if (!this.IsMobile && this.OrgListPanel.find("input").length == 0) {
                this.TreeManager.selectNode(this.TreeManager.data[0])
            }
        }, FocusOutput: function () {
            if (this.IsMobile) {
                return
            }
            if (this.SelectorPanel.is(":hidden")) {
                return
            }
            if (A(this.SearchTxtElement).val().length > 0) {
                this.OrgListPanel.html("");
                A(this.SearchTxtElement).val("")
            }
            this.SelectorPanel.hide()
        }, MappingControlsHandler: function (F) {
            if (!this.MappingControls) {
                return
            }
            var B = "";
            var D = {};
            var I = this.MappingControls.split(",");
            for (var E = 0; E < I.length; E++) {
                var H = I[E].split(":");
                D[H[0]] = H[1];
                B += H[1] + ";"
            }
            var G = this;
            var C = {Command: "GetUserProperty", Param: JSON.stringify([F.ObjectID, B])};
            A.MvcSheet.GetSheet(C, function (M) {
                for (var L in M) {
                    for (var J in D) {
                        if (D[J] == L) {
                            var K = A.MvcSheetUI.GetElement(J, G.RowNum);
                            if (K != null && K.data(A.MvcSheetUI.SheetIDKey)) {
                                K.SheetUIManager().SetValue(M[L])
                            }
                        }
                    }
                }
            })
        }, AddChoice: function (E) {
            if (!E) {
                return
            }
            if (!E.ObjectID) {
                return
            }
            if (this.Choices[E.ObjectID]) {
                return
            }
            if (!this.IsMultiple) {
                this.ClearChoices()
            }
            this.Choices[E.ObjectID] = E;
            if (this.MappingControls) {
                this.MappingControlsHandler(E)
            }
            if (!this.Editable) {
                A(this.Element).html(this.GetText());
                return
            }
            var B = A.MvcSheetUI.NewGuid();
            E.ChoiceID = B;
            var D = A("<li class='select2-search-choice'></li>");
            var F = A("<div>" + E.Name + "</div>");
            D.css("cursor", "pointer").css("margin-top", "2px").css("background-color", "#b0b0b0");
            D.attr("id", B).attr("data-code", E.ObjectID).append(F);
            if (this.IsMobile) {
                D.css("margin-top", "10px");
                this.ChoicesElement.append(D)
            } else {
                this.SearchElement.before(D);
                this.SetSearchTxtElementWidth.apply(this);
                this.ChoicesElement.append(D)
            }
            var C = A("<a href='javascript:void(0)' class='select2-search-choice-close'></a>");
            D.append(C);
            D.unbind("click.choice").bind("click.choice", this, function (G) {
                G.data.RemoveChoice.apply(G.data, [A(this).attr("data-code")])
            });
            this.Validate();
            if (this.IsMobile) {
                this.OnMobileChange()
            }
        }, OnMobileChange: function () {
            if (this.IsMobile) {
                var B = this;
                setTimeout(function () {
                    B.RefreshMobilePage()
                }, 100)
            }
        }, RefreshMobilePage: function () {
            if (A.ui.activeDiv.id == this.EditPanelID) {
                this.ChoicesPanel.height(A(this.ChoicesElement).outerHeight());
                if (this.SelectorPanel) {
                    this.SelectorPanel.outerHeight(A("#afui").height() - A("header:visible").outerHeight() - A("#footer:visible").outerHeight() - this.ChoicesPanel.outerHeight() - this.SearchElement.parent().outerHeight())
                }
            }
            var B = this;
            A(A.ui.activeDiv).find(".scroll-wrapper").each(function () {
                if (A(this).parent().is(".panel")) {
                    A(this).height(A("#afui").height() - (A("header:visible").height() || 0) - (A("footer:visible").height() || 0) + "px")
                }
                var C = B._GetScroller(this);
                if (C && C.refresh) {
                    C.refresh()
                }
            })
        }, _GetScroller: function (D) {
            this.IScrollers = this.IScrollers || {};
            var B = A(D).first();
            var C = B.data("scroller-id");
            if (!C) {
                C = A.uuid();
                B.data("scroller-id", C);
                this.IScrollers[C] = new IScroll(B.get(0))
            }
            return this.IScrollers[C]
        }, AddUserID: function (B) {
            var C = this;
            var D = {Command: "GetUserProperty", Param: JSON.stringify([B, "Name;ObjectID"])};
            A.ajax({
                type: "GET",
                url: window.location.href.replace("#", "&") + "&T=" + (Math.random() * 1000000).toString().substring(0, 6),
                data: D,
                dataType: "json",
                async: false,
                success: function (E) {
                    if (E) {
                        C.AddChoice({ObjectID: E["ObjectID"], Name: E["Name"]})
                    }
                }
            })
        }, ClearChoices: function () {
            for (var B in this.Choices) {
                this.RemoveChoice(B)
            }
            this.OnMobileChange()
        }, RemoveChoice: function (B) {
            if (this.Choices[B]) {
                this.OrgListPanel.find("input[ObjectID='" + B + "']").attr("checked", false);
                A("#" + this.Choices[B].ChoiceID).remove();
                delete this.Choices[B]
            }
            this.SetSearchTxtElementWidth.apply(this);
            this.Validate();
            this.OnMobileChange();
            if (this.OnChange) {
                this.RunScript(this, this.OnChange, [this])
            }
        }, LoadOrgTree: function () {
            if (!this.OrgTreePanel) {
                return
            }
            var B = A("<ul>").css("min-width", "180px");
            this.OrgTreePanel.append(B);
            if (!B.ligerTree) {
                A("body:first").append("<link rel='stylesheet' type='text/css' href='" + _PORTALROOT_GLOBAL + "/WFRes/_Content/themes/ligerUI/Aqua/css/ligerui-tree.css' />");
                A.ajax({
                    url: _PORTALROOT_GLOBAL + "/WFRes/_Scripts/ligerUI/ligerui.all.min.js",
                    type: "GET",
                    dataType: "script",
                    async: false,
                    global: false
                })
            }
            this.IsLoaded = false;
            this.TreeManager = A(B).ligerTree({
                checkbox: false,
                idFieldName: "Code",
                textFieldName: "Text",
                iconFieldName: "Icon",
                btnClickToToggleOnly: true,
                isExpand: 2,
                isLeaf: function (C) {
                    return C.IsLeaf
                },
                delay: function (C) {
                    var D = C.data;
                    if (D == null) {
                        return false
                    }
                    if (D.IsLeaf == null) {
                        return false
                    }
                    if (!D.IsLeaf && D.children == null) {
                        return D.LoadDataUrl
                    }
                    return false
                },
                url: this.SheetUserHandler + "?ParentCode=" + this.RootUnit + "&" + this.GetLoadTreeOption(),
                onSelect: this.TreeNodeClick,
                onCancelselect: this.TreeNodeClick,
                SheetUserManager: this,
                onSuccess: function () {
                    if (!this.options.SheetUserManager.IsLoaded) {
                        if (this.data.length > 0) {
                            this.options.SheetUserManager.TreeNodeClick.apply(this, [{data: this.data[0]}])
                        }
                        this.options.SheetUserManager.IsLoaded = true
                    }
                }
            })
        }, GetLoadTreeOption: function () {
            if (!this.__QueryOptions) {
                var B = "o=";
                var B = "o=";
                if (this.SegmentVisible) {
                    B += "S"
                }
                if (this.OrgUnitVisible) {
                    B += "O"
                }
                if (this.GroupVisible) {
                    B += "G"
                }
                if (this.PostVisible) {
                    B += "P"
                }
                if (this.UserVisible) {
                    B += "U"
                }
                if (this.VisibleUnits) {
                    B += "&VisibleUnits=" + this.VisibleUnits
                }
                if (this.RootUnit) {
                    B += "&RootUnit=" + this.RootUnit
                }
                if (this.RoleName) {
                    B += "&RoleName=" + encodeURI(this.RoleName)
                }
                if (this.OrgJobCode) {
                    B += "&OrgJobCode=" + encodeURI(this.OrgJobCode)
                }
                if (this.OrgPostCode) {
                    B += "&OrgPostCode=" + encodeURI(this.OrgPostCode)
                }
                if (this.OrgCode) {
                    B += "&OrgCode=" + encodeURI(this.OrgCode)
                }
                this.__QueryOptions = B
            }
            return this.__QueryOptions
        }, TreeNodeClick: function (D) {
            if (D == null) {
                return
            }
            if (D.data == null) {
                return
            }
            var E = D.data;
            var B = this.options.SheetUserManager;
            if (B.SelectedValue == E.ObjectID && !B.SearchMode) {
                return
            }
            B.SelectedValue = E.ObjectID;
            B.SearchMode = false;
            var C = B.GetLoadTreeOption();
            C = C.replace("&VisibleUnits=", "&V=");
            B.OrgListPanel.html("");
            A.ajax({
                type: "GET",
                url: B.SheetUserHandler + "?ParentID=" + E.ObjectID + "&" + C,
                dataType: "json",
                success: function (G) {
                    for (var F = 0; F < G.length; ++F) {
                        B.AddListItem.apply(B, [G[F]])
                    }
                }
            })
        }, SearchOrg: function (B) {
            var E = A(B.SearchTxtElement).val().trim();
            var D = new Date();
            if ((D - this.KeyTime) < 499) {
                return
            }
            if (!B.SearchKey && !E) {
                return
            }
            if (!E) {
                if (!this.IsMobile) {
                    B.SearchKey = E;
                    B.OrgListPanel.html("");
                    B.TreeManager.selectNode(B.TreeManager.nodes[0])
                } else {
                    B.OrgListPanel.html("")
                }
                return
            }
            B.SearchMode = true;
            B.SearchKey = E;
            B.OrgListPanel.html("");
            for (var F in B.SearchResults) {
                if (B.SearchResults[F].SearchKey == E && B.SearchResults[F].ParentID == B.SelectedValue) {
                    if (B.SearchResults[F].Data && B.SearchResults[F].Data.length) {
                        for (var C = 0; C < B.SearchResults[F].Data.length; ++C) {
                            B.AddListItem.apply(B, [B.SearchResults[F].Data[C], E])
                        }
                    } else {
                        B.OrgListPanel.html('<li class="user-item">没有任何组织</li>')
                    }
                    return
                }
            }
            A.ajax({
                type: "GET",
                url: B.SheetUserHandler + "?IsMobile=" + (!!this.IsMobile) + "&SearchKey=" + encodeURI(E) + "&SerachParentID=" + (B.SelectedValue || B.RootUnit || "") + "&" + B.GetLoadTreeOption(),
                dataType: "json",
                success: function (H) {
                    if (B.IsMobile) {
                        B.AddMobileOptions(H, B.OrgListPanel);
                        setTimeout(function () {
                            B.RefreshMobilePage()
                        }, 550)
                    } else {
                        if (H != null && H.length > 0) {
                            for (var G = 0; G < H.length; ++G) {
                                B.AddListItem.apply(B, [H[G], E])
                            }
                        } else {
                            B.OrgListPanel.html("<li class='user-item'>没搜索到组织</li>")
                        }
                    }
                    B.SearchResults.push({SearchKey: E, ParentID: B.SelectedValue, Data: H})
                }
            })
        }, AddListItem: function (F, D) {
            var B = F.Text;
            if (D) {
                B = B.replace(D, "<span class='bg-info'>" + D + "</span>");
                if (F.Text.indexOf("[" + F.Code + "]") == -1) {
                    B += "[" + F.Code.replace(D, "<span class='bg-info'>" + D + "</span>") + "]"
                }
            }
            if (this.IsMobile) {
                var I = A("<div></div>");
                I.css("border-bottom", "1px solid #ccc");
                I.height("50px");
                I.css("clear", "both");
                var G = A.MvcSheetUI.NewGuid();
                var E = A("<input type='checkbox' ObjectID='" + F.ObjectID + "' id='" + G + "'/>");
                I.append(E);
                I.append(A("<label type='checkbox' label-for='" + G + "'>" + B + "</label>").css("float", "none").css("left", "25px"));
                this.OrgListPanel.append(I);
                var C = this;
                I.bind("touchstart", function () {
                    E.click();
                    C.UnitCheckboxClick.apply(E.get(0), [C, {ObjectID: F.ObjectID, Name: F.Text}])
                })
            } else {
                var I = A("<div>").addClass("task").append("<i class='task-sort-icon fa  " + F.Icon + "'></i>").append("&nbsp;&nbsp;<span class='task-title' style='word-break: break-all;'>" + B + "</span>");
                I.css("padding", "5px 10px 5px 10px").css("border", "1px solid #e4e4e4").css("cursor", "pointer");
                var G = A.MvcSheetUI.NewGuid();
                var E = A("<input type='checkbox' ObjectID='" + F.ObjectID + "' id='" + G + "'/>").css("height", "auto").css("margin", "0px").show();
                var H = A("<div>").addClass("action-checkbox pull-right").append(E);
                I.click(function (J) {
                    if (J.target.tagName.toLowerCase() != "input") {
                        A(this).find("input").click()
                    }
                });
                this.OrgListPanel.append(I.append(H));
                E.attr("checked", this.Choices[F.ObjectID] != undefined);
                E.click({that: this, option: {ObjectID: F.ObjectID, Name: F.Text}}, function (J) {
                    J.data.that.UnitCheckboxClick.apply(this, [J.data.that, J.data.option])
                })
            }
        }, UnitCheckboxClick: function (B, C) {
            if (this.checked) {
                if (!B.IsMultiple) {
                    B.ClearChoices.apply(B);
                    B.OrgListPanel.find("input").attr("checked", false);
                    this.checked = true;
                    if (B.IsMobile && B.Level > 0) {
                        A.ui.goBack(B.Level);
                        B.Level = 0
                    }
                    B.FocusOutput.apply(B)
                }
                B.AddChoice.apply(B, [C])
            } else {
                if (B.IsMultiple) {
                    B.RemoveChoice.apply(B, [C.ObjectID])
                } else {
                    B.ClearChoices.apply(B)
                }
            }
            if (B.OnChange) {
                B.RunScript(this, B.OnChange, [B])
            }
        }
    })
})(jQuery);
jQuery.extend({
    MvcSheet: {
        Version: "V1.0",
        AjaxUrl: window.location.href.replace("#", "&") + "&T=" + (Math.random() * 1000000).toString().substring(0, 6),
        LOADKEY: "load",
        Actions: [],
        InitFunctions: [],
        ReadyFunctions: [],
        Action_Save: "Save",
        Action_ViewInstance: "ViewInstance",
        Action_PreviewParticipant: "PreviewParticipant",
        Action_Print: "Print",
        Action_CancelInstance: "CancelInstance",
        Action_Reject: "Reject",
        Action_Submit: "Submit",
        Action_FinishInstance: "FinishInstance",
        Action_Forward: "Forward",
        Action_Assist: "Assist",
        Action_Consult: "Consult",
        Action_Circulate: "Circulate",
        Action_AdjustParticipant: "AdjustParticipant",
        Action_LockInstance: "LockInstance",
        Action_UnLockInstance: "UnLockInstance",
        Action_Close: "Close",
        Action_RetrieveInstance: "RetrieveInstance",
        Action_Viewed: "Viewed",
        SaveAction: {
            Action: "Save",
            Icon: "fa-save",
            Text: "保存",
            en_us: "Save",
            OnActionPreDo: null,
            OnActionDone: null
        },
        PrintAction: {
            Action: "Print", Icon: "fa-print", Text: "打印", en_us: "Print", OnActionDone: function () {
            }
        },
        ViewedAction: {
            Action: "Viewed", Icon: "fa-check", Text: "已阅", en_us: "View", OnActionDone: function () {
            }
        },
        CancelInstanceAction: {Action: "CancelInstance", Icon: "fa-square-o", en_us: "Cancel", Text: "取消流程"},
        SubmitAction: {
            Action: "Submit", Icon: "fa-check", Text: "提交", en_us: "Submit", OnActionDone: function () {
            }
        },
        RejectAction: {
            Action: "Reject", Icon: "fa-mail-reply", Text: "驳回", en_us: "Reject", OnActionDone: function () {
            }
        },
        RetrieveInstanceAction: {Action: "RetrieveInstance", Icon: "fa-sign-in", en_us: "Retrieve", Text: "取回"},
        ViewInstanceAction: {Action: "ViewInstance", Icon: "fa-ellipsis-v", Text: "流程状态", en_us: "State"},
        PreviewParticipantAction: {Action: "PreviewParticipant", Icon: "fa-coumns", Text: "预览", en_us: "Preview"},
        FinishInstanceAction: {Action: "FinishInstance", Icon: "fa-square", Text: "结束流程", en_us: "Finish Instance"},
        ForwardAction: {Action: "Forward", Icon: "fa-mail-forward", Text: "转发", en_us: "Forward"},
        AssistAction: {Action: "Assist", Icon: "fa-qrcode", Text: "协办", en_us: "Assist"},
        ConsultAction: {Action: "Consult", Icon: "fa-phone", Text: "征询意见", en_us: "Consult"},
        CirculateAction: {Action: "Circulate", Icon: "fa-share-square-o", Text: "传阅", en_us: "Circulate"},
        AdjustParticipantAction: {Action: "AdjustParticipant", Icon: "fa-random", Text: "加签", en_us: "Plus"},
        LockInstanceAction: {Action: "LockInstance", Icon: "fa-unlock-alt", Text: "锁定", en_us: "Lock"},
        UnLockInstanceAction: {Action: "UnLockInstance", Icon: "fa-unlock-alt", Text: "解锁", en_us: "UnLock"},
        CloseAction: {Action: "Close", Icon: "fa-times", Text: "关闭", en_us: "Close"}
    }
});
if (!$.uuid) {
    $.uuid = function () {
        var A = function () {
            return (((1 + Math.random()) * 65536) | 0).toString(16).substring(1)
        };
        return (A() + A() + "-" + A() + "-" + A() + "-" + A() + "-" + A() + A() + A())
    }
}
jQuery.extend($.MvcSheet, {
    Init: function (A) {
        this.LoadData(A)
    }, InitToolBar: function () {
        if ($.MvcSheet.Actions.length == 0) {
            $.MvcSheet.AddDefaultActions()
        }
        var B = $(".SheetToolBar").SheetToolBar($.MvcSheet.Actions);
        if ($.MvcSheetUI.SheetInfo.IsMobile) {
            var A = [];
            var D = function (G, F) {
                return {
                    text: G.Text, handler: function () {
                        G.ActionClick()
                    }, actionKey: F
                }
            };
            for (_Action in B.ControlManagers) {
                var E = B.ControlManagers[_Action];
                if (E.MobileVisible) {
                    A.push(D(E, _Action))
                }
            }
            var C = $("#btnShowActions");
            if (A.length == 0) {
                C.hide()
            } else {
                if (A.length == 1) {
                    C.text(A[0].text);
                    C.click(function () {
                        B.ControlManagers[A[0].actionKey].ActionClick()
                    })
                } else {
                    C.click(function () {
                        $.ui.actionsheet(A)
                    })
                }
            }
        }
    }, InitHiddenFields: function () {
        $("input:hidden").each(function () {
            if ($(this).data("type") == "SheetHiddenField") {
                $(this).SheetHiddenField()
            }
        })
    }, LoadData: function (A) {
        var B = "正在努力加载...";
        $.MvcSheetUI.Loading = true;
        if (this.AjaxUrl.toLowerCase().indexOf("ismobile") > -1) {
            B = ""
        }
        $.LoadingMask.Show(B, false);
        $(".divContent:last").append('<div class="row tableContent"><div class="col-md-2"><span data-type="SheetLabel" data-datafield="Sheet__ConsultComment">征询意见</span></div><div class="col-md-10"><div data-datafield="Sheet__ConsultComment" data-type="SheetComment"></div></div></div>');
        this.GetSheet({"Command": this.LOADKEY}, function (D) {
            $.MvcSheetUI.SheetInfo = D;
            if (D.Message) {
                alert(D.Message);
                if (D.Close) {
                    $.MvcSheet.ClosePage();
                    return
                }
            }
            $.MvcSheet.PreInit.apply(this, [$.MvcSheetUI.SheetInfo]);
            if ($.MvcSheet.InitFunctions.length > 0) {
                for (var I = 0; I < $.MvcSheet.InitFunctions.length; I++) {
                    $.MvcSheet.InitFunctions[I].call(this, $.MvcSheetUI.SheetInfo)
                }
            }
            $.MvcSheet.PreInitLanguage();
            $.MvcSheet.InitToolBar();
            var N = $("[" + $.MvcSheetUI.PreDataKey + $.MvcSheetUI.DataFieldKey.toLowerCase() + "]");
            var H = [];
            var G = [];
            for (var I = 0, K = N.length; I < K; I++) {
                var L = N[I];
                if (L.tagName.toLowerCase() == "table") {
                    G.push(L)
                } else {
                    if ($(L).parents("tr.template").length == 0) {
                        H.push(L)
                    }
                }
            }
            for (I = 0, K = H.length; I < K; I++) {
                $(H[I]).SheetUIManager()
            }
            for (I = 0, K = G.length; I < K; I++) {
                $(G[I]).SheetUIManager()
            }
            $.MvcSheet.InitHiddenFields();
            if ($.MvcSheetUI.SheetInfo.IsMobile) {
                var F = false;
                for (c in $.MvcSheetUI.ControlManagers) {
                    if ($.MvcSheetUI.ControlManagers[c] instanceof $.MvcSheetUI.Controls.SheetComment) {
                        var M = $($.MvcSheetUI.ControlManagers[c].Element).parent("div");
                        var J = $($.MvcSheetUI.ControlManagers[c].Element).parent("div").prev(".col-md-2");
                        $(J).removeClass("col-md-2").addClass("bannerTitle");
                        var E = $.MvcSheetUI.ControlManagers[c].Element;
                        var C = $(E).parents("div.panel-body");
                        $(E).addClass("sheet-comment");
                        if ($.MvcSheetUI.ControlManagers[c].Editable && !F) {
                            $(E).prependTo(C);
                            $(J).prependTo(C);
                            F = true
                        } else {
                            $(C).append(J);
                            $(J).after(E)
                        }
                        M.hide()
                    }
                }
                $(".col-md-2,.col-md-4,col-md-10").filter(function () {
                    return $(this).children().length == 0 && (!$(this).text() || $(this).text().trim() == "")
                }).hide()
            } else {
                $("div[class^='col-md-']").each(function () {
                    var R = true;
                    if ($(this).text()) {
                        R = false
                    } else {
                        var S = $(this).find("[" + $.MvcSheetUI.PreDataKey + $.MvcSheetUI.DataFieldKey.toLowerCase() + "]");
                        for (var P = 0; P < S.length; P++) {
                            var Q = $(S).SheetUIManager();
                            if (!Q) {
                                var O = $(S).attr($.MvcSheetUI.PreDataKey + $.MvcSheetUI.DataFieldKey.toLowerCase());
                                alert("数据项:{" + O + "}不存在");
                                return
                            }
                            if (Q.Visiable) {
                                R = false;
                                break
                            }
                        }
                    }
                    if (R) {
                        $(this).hide()
                    }
                });
                $("div[class='row']").each(function () {
                    if ($(this).find("div:visible[class^='col-md-']").length == 0) {
                        $(this).hide()
                    }
                })
            }
            if (typeof (A) == "function") {
                A()
            }
            $.MvcSheet.RenderLanguage();
            $.MvcSheet.Rendered.apply(this, [$.MvcSheetUI.SheetInfo]);
            $.MvcSheetUI.Loading = false;
            $.LoadingMask.Hide();
            $.MvcSheet.Loaded.apply(this, [$.MvcSheetUI.SheetInfo]);
            if ($.MvcSheet.ReadyFunctions.length > 0) {
                for (var I = 0; I < $.MvcSheet.ReadyFunctions.length; I++) {
                    $.MvcSheet.ReadyFunctions[I].call(this, $.MvcSheetUI.SheetInfo)
                }
            }
        }, function (C) {
            alert("表单数据加载失败，请稍候再试!")
        })
    }, Ready: function (A) {
        $.MvcSheet.ReadyFunctions.push(A)
    }, PreInitLanguage: function () {
        var A = $.MvcSheetUI.SheetInfo.Language;
        if (typeof (SheetLanguages[A]) == "undefined" || SheetLanguages[A] == null) {
            A = "zh_cn"
        }
        $.extend(SheetLanguages.Current, SheetLanguages[A])
    }, RenderLanguage: function () {
        var A = $.MvcSheetUI.SheetInfo.Language;
        if (A) {
            A = $.MvcSheetUI.PreDataKey + A.replace("-", "_");
            $("span[" + A + "],label[" + A + "]").each(function () {
                $(this).html($(this).attr(A))
            })
        }
    }, PreInit: function () {
    }, PreLoad: function (A) {
        $.MvcSheet.InitFunctions.push(A)
    }, Loaded: function () {
    }, Rendered: function () {
        $("input,textarea,select").addClass($.MvcSheetUI.Css.inputMouseOut).unbind("mouseover.style").bind("mouseover.style", function () {
            var D = $(this);
            if (D.parent().is("li") && D.parent().parent().parent().is("div")) {
                D = D.parent().parent().parent()
            }
            D.removeClass($.MvcSheetUI.Css.inputMouseOut).addClass($.MvcSheetUI.Css.inputMouseMove)
        }).unbind("mouseenter.style").bind("mouseenter.style", function () {
            var D = $(this);
            if (D.parent().is("li") && D.parent().parent().parent().is("div")) {
                D = D.parent().parent().parent()
            }
            D.removeClass($.MvcSheetUI.Css.inputMouseMove).addClass($.MvcSheetUI.Css.inputMouseEnter)
        }).unbind("mouseout.style").bind("mouseout.style", function () {
            var D = $(this);
            if (D.parent().is("li") && D.parent().parent().parent().is("div")) {
                D = D.parent().parent().parent()
            }
            D.removeClass($.MvcSheetUI.Css.inputMouseEnter).removeClass($.MvcSheetUI.Css.inputMouseMove).addClass($.MvcSheetUI.Css.inputMouseOut)
        });
        if ($.MvcSheetUI.SheetInfo.IsMobile) {
            var C = $("select[data-datafield]");
            if (C && C.length > 0) {
                for (var A = 0; A < C.length; A++) {
                    var B = $(C[A]).SheetUIManager();
                    if ($(C[A]).attr("data-datafield").indexOf(".") > -1) {
                        B = $(C[A]).SheetUIManager($(C[A]).parent().parent().attr("data-row"))
                    }
                    if (B && !B.Editable) {
                        $(C[A]).siblings(".afFakeSelect").hide()
                    }
                }
            }
        }
        $.MvcSheetUI.MvcRuntime = new Sheet()
    }, Action: function (A) {
        if (typeof (A.Mask) == "undefined" || A.Mask) {
            $.LoadingMask.Show((A.Text || SheetLanguages.Current.Doing) + "...")
        }
        var B = A.Action;
        var H = A.Datas;
        var C = {Command: B};
        var D = [];
        if (typeof (A.LoadControlValue) == "undefined" || A.LoadControlValue) {
            if (H) {
                for (var E = 0; E < H.length; E++) {
                    if (H[E].toString().indexOf("{") == 0) {
                        var G = H[E].replace("{", "").replace("}", "");
                        D.push($.MvcSheetUI.GetControlValue(G))
                    } else {
                        if (H[E].toString().indexOf("#") == 0) {
                            var G = H[E].replace("#");
                            D.push($.MvcSheetUI.GetControlValue(H[E]))
                        } else {
                            D.push(H[E])
                        }
                    }
                }
            }
        } else {
            D = H
        }
        C["Param"] = JSON.stringify(D);
        if (A.PostSheetInfo) {
            C["MvcPostValue"] = JSON.stringify(this.GetMvcPostValue(this.actionName))
        }
        var F = this;
        this.PostSheet(C, function (I) {
            if (A.OnActionDone) {
                A.OnActionDone.apply(A, [I])
            }
            F.ResultHandler.apply(F, [A, I]);
            if (A.CloseAfterAction) {
                $.MvcSheet.ClosePage()
            }
            $.LoadingMask.Hide()
        }, undefined, A.Async)
    }, ConfirmAction: function (B, A) {
        if ($.ui && $.ui.popup) {
            $.ui.blockUI(0.5);
            $.ui.popup({
                title: SheetLanguages.Current.Notice,
                message: B,
                doneText: SheetLanguages.Current.OK,
                cancelText: SheetLanguages.Current.Cancel,
                cancelOnly: false,
                doneCallback: function (C) {
                    A()
                }
            })
        } else {
            if (confirm(B)) {
                A()
            }
        }
    }, ActionValidata: function (A, C) {
        var B = true;
        if (this.Validate) {
            B = this.Validate.apply(A)
        }
        if (B || B == undefined) {
            return $.MvcSheetUI.Validate(A, C)
        } else {
            return false
        }
    }, Save: function (A) {
        if (!$.MvcSheet.ActionValidata(A, true)) {
            return false
        }
        $.LoadingMask.Show(SheetLanguages.Current.Saving);
        var C = this.GetMvcPostValue(this.Action_Save);
        var B = this;
        this.PostSheet({Command: this.Action_Save, MvcPostValue: JSON.stringify(C)}, function (D) {
            B.ResultHandler.apply(B, [A, D])
        })
    }, Submit: function (A, D, F, C, E) {
        if (!$.MvcSheet.ActionValidata(A)) {
            return false
        }
        var B = this;
        $.MvcSheet.ConfirmAction(SheetLanguages.Current.ConfirmDo + "[" + D + "]" + SheetLanguages.Current.Operation + "?", function () {
            $.LoadingMask.Show(SheetLanguages.Current.Sumiting);
            var G = B.GetMvcPostValue(B.Action_Submit, F, C, E);
            B.PostSheet({Command: B.Action_Submit, MvcPostValue: JSON.stringify(G)}, function (H) {
                B.ResultHandler.apply(B, [A, H])
            })
        })
    }, ControlInit: function () {
    }, ControlPreRender: function () {
    }, ControlRendered: function () {
    }, Reject: function (A, C) {
        A.IsReject = true;
        if (!$.MvcSheet.ActionValidata(A)) {
            return false
        }
        $.LoadingMask.Show(SheetLanguages.Current.Rejecting);
        var D = this.GetMvcPostValue(this.Action_Reject, C);
        var B = this;
        this.PostSheet({Command: this.Action_Reject, MvcPostValue: JSON.stringify(D)}, function (E) {
            B.ResultHandler.apply(B, [A, E])
        })
    }, FinishInstance: function (A) {
        $.LoadingMask.Show(SheetLanguages.Current.Finishing);
        var C = this.GetMvcPostValue(this.Action_FinishInstance);
        var B = this;
        this.PostSheet({Command: this.Action_FinishInstance, MvcPostValue: JSON.stringify(C)}, function (D) {
            B.ResultHandler.apply(B, [A, D])
        })
    }, RetrieveInstance: function (A) {
        $.LoadingMask.Show(SheetLanguages.Current.Retrieving);
        var B = this;
        this.GetSheet({Command: this.Action_RetrieveInstance}, function (C) {
            B.ResultHandler.apply(B, [A, C])
        })
    }, GetMvcPostValue: function (A, D, B, C) {
        var E = {
            Command: A,
            DestActivityCode: D,
            PostValue: B,
            GroupValue: C,
            BizObjectId: $.MvcSheetUI.SheetInfo.BizObjectID,
            InstanceId: $.MvcSheetUI.SheetInfo.InstanceId,
            BizObject: {}
        };
        E.BizObject.DataItems = $.MvcSheetUI.SaveSheetData(A);
        E.Priority = $.MvcSheetUI.Priority;
        E.HiddenFields = $.MvcSheetUI.HiddenFields;
        return E
    }, ResultHandler: function (A, D) {
        if ($.MvcSheet.ActionDone) {
            $.MvcSheet.ActionDone.apply(A, [D])
        }
        if (D == "undefined" || D == null) {
            return
        }
        if (D.Successful) {
            if ($.MvcSheetUI.SheetInfo.IsMobile) {
                window.location.href = D.MobileReturnUrl
            } else {
                if (D.ClosePage) {
                    $.MvcSheet.ClosePage()
                } else {
                    if (D.Url) {
                        window.location.href = D.Url
                    } else {
                        if (D.Message) {
                            if (D.Refresh) {
                                var C = window.location.href;
                                C = C.replace("&T=", "&T=" + Math.round(Math.random() * 100, 0));
                                window.location.href = C
                            }
                        } else {
                        }
                    }
                }
            }
        } else {
            if (D.Errors) {
                for (var B = 0; B < D.Errors.length; B++) {
                    alert(D.Errors[B])
                }
            }
        }
        $.LoadingMask.Hide()
    }, ClosePage: function () {
        if (window.opener != null && window.opener.location != null && window.opener.location.href != window.location.href && $.MvcSheetUI.QueryString("Mode").toLowerCase() != "originate") {
            window.opener.location.reload()
        }
        window.opener = null;
        window.open("", "_self");
        window.close()
    }, AddDefaultActions: function () {
        this.Actions.splice(0, this.Actions.length, this.RetrieveInstanceAction, this.SaveAction, this.ViewInstanceAction, this.PreviewParticipantAction, this.PrintAction, this.ViewedAction, this.CancelInstanceAction, this.SubmitAction, this.RejectAction, this.FinishInstanceAction, this.ForwardAction, this.AssistAction, this.ConsultAction, this.CirculateAction, this.AdjustParticipantAction, this.LockInstanceAction, this.UnLockInstanceAction, this.CloseAction)
    }, AddAction: function (A) {
        if ($.MvcSheetToolbar.AddButton) {
            $.MvcSheetToolbar.AddButton(A)
        } else {
            if (this.Actions.length == 0) {
                this.AddDefaultActions()
            }
        }
        if (A.PreAction) {
            for (var B in this.Actions) {
                if (this.Actions[B].Action == A.PreAction) {
                    if (B < this.Actions.length - 1) {
                        B++
                    }
                    this.Actions.splice(B, 0, A);
                    break
                }
            }
        } else {
            this.Actions.push(A)
        }
    }, GetSheet: function (D, A, B, C) {
        $.ajax({
            type: "GET",
            url: this.AjaxUrl,
            data: D,
            dataType: "json",
            async: C != null ? C : true,
            success: A,
            error: B
        })
    }, PostSheet: function (E, A, C, D) {
        var B = this.AjaxUrl;
        if (B.toLowerCase().indexOf("&bizobjectid=") == -1) {
            B = this.AjaxUrl + "&BizObjectID=" + $.MvcSheetUI.SheetInfo.BizObjectID
        }
        if (typeof (D) == "undefined") {
            D = true
        }
        if (typeof (C) == "undefined") {
            C = function (F) {
                alert("系统出现异常!");
                $.LoadingMask.Hide()
            }
        }
        $.ajax({type: "POST", url: B, data: E, dataType: "json", async: D, success: A, error: C})
    }
});
